|
@@ -124,13 +124,10 @@ public class InBoxServiceImpl implements IInBoxService { |
|
@@ -124,13 +124,10 @@ public class InBoxServiceImpl implements IInBoxService { |
124
|
}
|
124
|
}
|
125
|
|
125
|
|
126
|
private void setInboxByRedis(ListInboxReqVO reqVO, List<InBox> inBoxes, int total) {
|
126
|
private void setInboxByRedis(ListInboxReqVO reqVO, List<InBox> inBoxes, int total) {
|
127
|
- RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_LIST.generateKey(reqVO.getUid(),reqVO.getType(),reqVO.getPage(),reqVO.getLimit());
|
|
|
128
|
- if(null == inBoxes){
|
|
|
129
|
- redisTemplate.delete(inboxKey);
|
|
|
130
|
- }else{
|
|
|
131
|
- redisTemplate.setEx(inboxKey,inBoxes,CacheEnum.USERS_INBOX_LIST.getCacheTime());
|
|
|
132
|
- }
|
|
|
133
|
- RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(reqVO.getUid(),reqVO.getType());
|
127
|
+ RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_LIST.generateKey(reqVO.getUid());
|
|
|
128
|
+ redisTemplate.put(inboxKey, CacheKeyHelper.getInboxRedisHashKey(reqVO.getType(),reqVO.getPage(),reqVO.getLimit()),
|
|
|
129
|
+ inBoxes,CacheEnum.USERS_INBOX_LIST.getCacheTime());
|
|
|
130
|
+ RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(reqVO.getUid(),reqVO.getType() == null ?"N":reqVO.getType());
|
134
|
redisTemplate.setEx(inboxTotalKey,total,CacheEnum.USERS_INBOX_LIST_TOTAL.getCacheTime());
|
131
|
redisTemplate.setEx(inboxTotalKey,total,CacheEnum.USERS_INBOX_LIST_TOTAL.getCacheTime());
|
135
|
}
|
132
|
}
|
136
|
|
133
|
|
|
@@ -146,9 +143,9 @@ public class InBoxServiceImpl implements IInBoxService { |
|
@@ -146,9 +143,9 @@ public class InBoxServiceImpl implements IInBoxService { |
146
|
private PageResponseVO<InBox> listInboxByRedis(ListInboxReqVO reqVO) {
|
143
|
private PageResponseVO<InBox> listInboxByRedis(ListInboxReqVO reqVO) {
|
147
|
PageResponseVO<InBox> response = new PageResponseVO<>();
|
144
|
PageResponseVO<InBox> response = new PageResponseVO<>();
|
148
|
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_LIST.generateKey(reqVO.getUid());
|
145
|
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_LIST.generateKey(reqVO.getUid());
|
149
|
- List<InBox> inboxes = redisTemplate.get(inboxKey, CacheKeyHelper.getInboxRedisHashKey(reqVO.getType(),reqVO.getPage(),reqVO.getLimit()),List.class);
|
|
|
150
|
- RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(reqVO.getUid());
|
|
|
151
|
- Integer total = redisTemplate.get(inboxTotalKey,CacheKeyHelper.getInboxTotalRedisHashKey(reqVO.getType()),Integer.class);
|
146
|
+ List<InBox> inboxes = redisTemplate.getList(inboxKey, CacheKeyHelper.getInboxRedisHashKey(reqVO.getType(),reqVO.getPage(),reqVO.getLimit()),InBox.class);
|
|
|
147
|
+ RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(reqVO.getUid(),reqVO.getType() == null ?"N":reqVO.getType());
|
|
|
148
|
+ Integer total = redisTemplate.get(inboxTotalKey,Integer.class);
|
152
|
if(inboxes == null || total == null){
|
149
|
if(inboxes == null || total == null){
|
153
|
log.info("listInboxByRedis cache is empty.inboxes is {},inboxKey is {}," +
|
150
|
log.info("listInboxByRedis cache is empty.inboxes is {},inboxKey is {}," +
|
154
|
"total is {},totalKey is {}",inboxes,inboxKey,total,inboxTotalKey);
|
151
|
"total is {},totalKey is {}",inboxes,inboxKey,total,inboxTotalKey);
|
|
@@ -179,14 +176,19 @@ public class InBoxServiceImpl implements IInBoxService { |
|
@@ -179,14 +176,19 @@ public class InBoxServiceImpl implements IInBoxService { |
179
|
inBox.setContent(createContent(businessTypeEnum.getContent(),params));
|
176
|
inBox.setContent(createContent(businessTypeEnum.getContent(),params));
|
180
|
inBox.setBusinessType(businessType);
|
177
|
inBox.setBusinessType(businessType);
|
181
|
inBoxDao.insertInbox(getTableName(inBox.getUid()),inBox);
|
178
|
inBoxDao.insertInbox(getTableName(inBox.getUid()),inBox);
|
182
|
- deleteIboxsByRedis(uid);
|
179
|
+ deleteIboxsByRedis(uid,type);
|
183
|
}
|
180
|
}
|
184
|
|
181
|
|
185
|
- private void deleteIboxsByRedis(int uid){
|
182
|
+ private void deleteIboxsByRedis(int uid,int type){
|
|
|
183
|
+ log.info("deleteIboxsByRedis params uid is {} type is {}",uid,type);
|
186
|
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_LIST.generateKey(uid);
|
184
|
RedisKeyBuilder inboxKey = CacheEnum.USERS_INBOX_LIST.generateKey(uid);
|
187
|
redisTemplate.delete(inboxKey);
|
185
|
redisTemplate.delete(inboxKey);
|
188
|
- RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid);
|
186
|
+ RedisKeyBuilder key = CacheEnum.USERS_INBOX_TYPE_UNREADCOUNT.generateKey(uid,type);
|
|
|
187
|
+ redisTemplate.delete(key);
|
|
|
188
|
+ RedisKeyBuilder inboxTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,"N");
|
189
|
redisTemplate.delete(inboxTotalKey);
|
189
|
redisTemplate.delete(inboxTotalKey);
|
|
|
190
|
+ RedisKeyBuilder inboxTypeTotalKey = CacheEnum.USERS_INBOX_LIST_TOTAL.generateKey(uid,type);
|
|
|
191
|
+ redisTemplate.delete(inboxTypeTotalKey);
|
190
|
}
|
192
|
}
|
191
|
|
193
|
|
192
|
private String createContent(String template, String params){
|
194
|
private String createContent(String template, String params){
|