cacheResult.setHit(true);
return cacheResult;
}
private void afterDataAccess(CacheResult cacheResult, Object[] args) throws CacheUnreachableException {
CacheDefinition cacheDefinition = cacheDefinitionCollection.getCacheDefinition();
if (cacheDefinition == null) {
updateVersion(cacheResult, args);
deleteCache(cacheResult, args);
return;
}
String key = cacheResult.getKey();
Object exeResult = cacheResult.getRetVal();
Cache cache = cacheResult.getCache();
cacheResult = recacheVersionKey(cacheResult, args, cacheDefinition);
long expire = cacheDefinition.getExpire();
long currentVersion = cacheResult.getCurrentVersion();
CacheObject newItem = new CacheObject((Serializable) exeResult, currentVersion);
cache.add(key, newItem, expire);
LOGGER.debug("缓存对象到:" + key + ",缓存时间:" + expire + "毫秒");
if (cacheDefinition.isReturnCollection()) {
int pageIndex = cacheDefinition.getPageIndex();
Page page = CommonUtils.getPageArgument(args, pageIndex);
if (page != null) {
String pageKey = cacheResult.getPageKey();
if (pageKey == null) {
pageKey = cacheDefinition.generatePageKey(args, key);
}
if (!StringUtils.isEmpty(pageKey)) {
cache.add(pageKey, page, expire);
LOGGER.debug("缓存为需要分页的缓存,页码(" + page.getCurpage() + "),缓存分页对象到:" + pageKey + ", 缓存时间:" + expire + "毫秒");
}