String pageKey = RedisKeyManagement.getKey(RedisKeyManagement.ACTIVITY_BAISHI_PAGE_CACHE,
Arrays.asList(activityId.toString(),String.valueOf(current)));
Object pageObj = redisService.get(pageKey);
if(pageObj != null) {
return ApiResult.success(pageObj);
}
// 字符串对象要.intern()很重要
synchronized (("lock" + activityId + current).intern()) {
pageObj = redisService.get(pageKey);
if(pageObj != null) {
return ApiResult.success(pageObj);
}
ApiResult<PortalPageVO<PlayRecordBaseExtendVO>> apiResult = 读数据库的请求;
redisService.set(pageKey,apiResult.getData(), Constant.TEN_SECOND);
return apiResult;
}
参考:
https://blog.csdn.net/A_art_xiang/article/details/126340579
标签:缓存,return,分页,redisService,pageObj,apiResult,redis,pageKey From: https://www.cnblogs.com/maohuidong/p/16666887.html