Commit 65981e3f by WeiCong

优化缓存模块

parent 4a9d88d8
......@@ -30,7 +30,7 @@ public abstract class AbstractCache implements CacheController {
Object o = cacheKey.getKey();
String fullSizeKey = generateKey(o);
Integer fullSize = (Integer) doCacheRead(fullSizeKey);
if(fullSize == null)
if (fullSize == null)
fullSize = 0;
if (fullSize == 0) {
try {
......@@ -41,7 +41,13 @@ public abstract class AbstractCache implements CacheController {
}
}
String valKey = generateValKey(o, maxSize, offset);
List lst = (List) doCacheRead(valKey);
Object lstobj = doCacheRead(valKey);
List lst = null;
if (lstobj != null && List.class.isAssignableFrom(lstobj.getClass())) {
lst = List.class.cast(lstobj);
} else {
lst = null;
}
if (lst == null) {
if (o instanceof Criteria) {
Criteria criteria = (Criteria) o;
......@@ -75,8 +81,10 @@ public abstract class AbstractCache implements CacheController {
throw new NoUiException("[" + this.cacheName + "]执行sql出现异常", e);
}
}
if (lst != null) {
doCacheWrite(valKey, lst, keepAlive);
}
}
return new CacheList(lst, fullSize);
}
......@@ -86,7 +94,7 @@ public abstract class AbstractCache implements CacheController {
sb.append(SPLIT.intern());
sb.append(maxSize);
}
if (offset > 0) {
if (offset >= 0) {
sb.append(SPLIT.intern());
sb.append(offset);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment