...
|
...
|
@@ -124,13 +124,10 @@ public class InBoxServiceImpl implements IInBoxService { |
|
|
}
|
|
|
|
|
|
private void setInboxByRedis(ListInboxReqVO reqVO, List<InBox> inBoxes, int total) {
|
|
|
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_LIST.generateKey(reqVO.getUid(),reqVO.getType(),reqVO.getPage(),reqVO.getLimit());
|
|
|
if(null == inBoxes){
|
|
|
redisTemplate.delete(inboxKey);
|
|
|
}else{
|
|
|
redisTemplate.setEx(inboxKey,inBoxes,CacheEnum.USERS_INBOX_LIST.getCacheTime());
|
|
|
}
|
|
|
RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(reqVO.getUid(),reqVO.getType());
|
|
|
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_LIST.generateKey(reqVO.getUid());
|
|
|
redisTemplate.put(inboxKey, CacheKeyHelper.getInboxRedisHashKey(reqVO.getType(),reqVO.getPage(),reqVO.getLimit()),
|
|
|
inBoxes,CacheEnum.USERS_INBOX_LIST.getCacheTime());
|
|
|
RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(reqVO.getUid(),reqVO.getType() == null ?"N":reqVO.getType());
|
|
|
redisTemplate.setEx(inboxTotalKey,total,CacheEnum.USERS_INBOX_LIST_TOTAL.getCacheTime());
|
|
|
}
|
|
|
|
...
|
...
|
@@ -146,9 +143,9 @@ public class InBoxServiceImpl implements IInBoxService { |
|
|
private PageResponseVO<InBox> listInboxByRedis(ListInboxReqVO reqVO) {
|
|
|
PageResponseVO<InBox> response = new PageResponseVO<>();
|
|
|
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_LIST.generateKey(reqVO.getUid());
|
|
|
List<InBox> inboxes = redisTemplate.get(inboxKey, CacheKeyHelper.getInboxRedisHashKey(reqVO.getType(),reqVO.getPage(),reqVO.getLimit()),List.class);
|
|
|
RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(reqVO.getUid());
|
|
|
Integer total = redisTemplate.get(inboxTotalKey,CacheKeyHelper.getInboxTotalRedisHashKey(reqVO.getType()),Integer.class);
|
|
|
List<InBox> inboxes = redisTemplate.getList(inboxKey, CacheKeyHelper.getInboxRedisHashKey(reqVO.getType(),reqVO.getPage(),reqVO.getLimit()),InBox.class);
|
|
|
RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(reqVO.getUid(),reqVO.getType() == null ?"N":reqVO.getType());
|
|
|
Integer total = redisTemplate.get(inboxTotalKey,Integer.class);
|
|
|
if(inboxes == null || total == null){
|
|
|
log.info("listInboxByRedis cache is empty.inboxes is {},inboxKey is {}," +
|
|
|
"total is {},totalKey is {}",inboxes,inboxKey,total,inboxTotalKey);
|
...
|
...
|
@@ -179,14 +176,19 @@ public class InBoxServiceImpl implements IInBoxService { |
|
|
inBox.setContent(createContent(businessTypeEnum.getContent(),params));
|
|
|
inBox.setBusinessType(businessType);
|
|
|
inBoxDao.insertInbox(getTableName(inBox.getUid()),inBox);
|
|
|
deleteIboxsByRedis(uid);
|
|
|
deleteIboxsByRedis(uid,type);
|
|
|
}
|
|
|
|
|
|
private void deleteIboxsByRedis(int uid){
|
|
|
private void deleteIboxsByRedis(int uid,int type){
|
|
|
log.info("deleteIboxsByRedis params uid is {} type is {}",uid,type);
|
|
|
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_LIST.generateKey(uid);
|
|
|
redisTemplate.delete(inboxKey);
|
|
|
RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid);
|
|
|
RedisKeyBuilder key = CacheEnum.USERS_INBOX_TYPE_UNREADCOUNT.generateKey(uid,type);
|
|
|
redisTemplate.delete(key);
|
|
|
RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,"N");
|
|
|
redisTemplate.delete(inboxTotalKey);
|
|
|
RedisKeyBuilder inboxTypeTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,type);
|
|
|
redisTemplate.delete(inboxTypeTotalKey);
|
|
|
}
|
|
|
|
|
|
private String createContent(String template, String params){
|
...
|
...
|
|