提交 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 { ...@@ -58,6 +58,10 @@ public class RedissonCache implements Cache {
@Override @Override
public Object getObject(Object o) { public Object getObject(Object o) {
check(); check();
if (maxIdleTime == 0 && maxSize == 0) {
return mapCache.getWithTTLOnly(o);
}
return mapCache.get(o); return mapCache.get(o);
} }
......
...@@ -70,7 +70,13 @@ public class RedissonCache implements Cache { ...@@ -70,7 +70,13 @@ public class RedissonCache implements Cache {
@Override @Override
public ValueWrapper get(Object key) { 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) { if (value == null) {
addCacheMiss(); addCacheMiss();
} else { } else {
...@@ -80,7 +86,13 @@ public class RedissonCache implements Cache { ...@@ -80,7 +86,13 @@ public class RedissonCache implements Cache {
} }
public <T> T get(Object key, Class<T> type) { 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) { if (value == null) {
addCacheMiss(); addCacheMiss();
} else { } else {
...@@ -151,7 +163,13 @@ public class RedissonCache implements Cache { ...@@ -151,7 +163,13 @@ public class RedissonCache implements Cache {
} }
public <T> T get(Object key, Callable<T> valueLoader) { 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) { if (value == null) {
addCacheMiss(); addCacheMiss();
RLock lock = map.getLock(key); RLock lock = map.getLock(key);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册