Commit ecadd0e6 by fukai

将计算总数大小顺序调整至查数之后

parent e27ae168
......@@ -29,17 +29,7 @@ public abstract class AbstractCache implements CacheController {
public CacheList cacheRead(CacheKey cacheKey, long keepAlive, int maxSize, int offset) {
Object o = cacheKey.getKey();
String fullSizeKey = generateKey(o);
Integer fullSize = (Integer) doCacheRead(fullSizeKey);
if (fullSize == null)
fullSize = 0;
if (fullSize == 0) {
try {
fullSize = cacheKey.getFullSize();
doCacheWrite(fullSizeKey, fullSize, keepAlive);
} catch (Exception e) {
throw new NoUiException("[" + this.cacheName + "]执行getFullSize时出现异常", e);
}
}
String valKey = generateValKey(o, maxSize, offset);
Object lstobj = doCacheRead(valKey);
List lst = null;
......@@ -85,6 +75,19 @@ public abstract class AbstractCache implements CacheController {
doCacheWrite(valKey, lst, keepAlive);
}
}
Integer fullSize = (Integer) doCacheRead(fullSizeKey);
if (fullSize == null)
fullSize = 0;
if (fullSize == 0) {
try {
fullSize = cacheKey.getFullSize();
doCacheWrite(fullSizeKey, fullSize, keepAlive);
} catch (Exception e) {
throw new NoUiException("[" + this.cacheName + "]执行getFullSize时出现异常", e);
}
}
return new CacheList(lst, fullSize);
}
......
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