提交 42967e2f 编写于 作者: N Nikita Koksharov

Improvement - spring and mybatis cache should read data from Redis slave if...

Improvement - spring and mybatis cache should read data from Redis slave if idleTime and cache size weren't specified.
上级 b0bb6036
......@@ -58,6 +58,10 @@ public class RedissonCache implements Cache {
@Override
public Object getObject(Object o) {
check();
if (maxIdleTime == 0 && maxSize == 0) {
return mapCache.getWithTTLOnly(o);
}
return mapCache.get(o);
}
......
......@@ -70,7 +70,13 @@ public class RedissonCache implements Cache {
@Override
public ValueWrapper get(Object key) {
Object value = map.get(key);
Object value;
if (mapCache != null && config.getMaxIdleTime() == 0 && config.getMaxSize() == 0) {
value = mapCache.getWithTTLOnly(key);
} else {
value = map.get(key);
}
if (value == null) {
addCacheMiss();
} else {
......@@ -80,7 +86,13 @@ public class RedissonCache implements Cache {
}
public <T> T get(Object key, Class<T> type) {
Object value = map.get(key);
Object value;
if (mapCache != null && config.getMaxIdleTime() == 0 && config.getMaxSize() == 0) {
value = mapCache.getWithTTLOnly(key);
} else {
value = map.get(key);
}
if (value == null) {
addCacheMiss();
} else {
......@@ -151,7 +163,13 @@ public class RedissonCache implements Cache {
}
public <T> T get(Object key, Callable<T> valueLoader) {
Object value = map.get(key);
Object value;
if (mapCache != null && config.getMaxIdleTime() == 0 && config.getMaxSize() == 0) {
value = mapCache.getWithTTLOnly(key);
} else {
value = map.get(key);
}
if (value == null) {
addCacheMiss();
RLock lock = map.getLock(key);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册