修复小程序端redisKey有效时间不同步的问题

This commit is contained in:
wen 2022-01-13 19:21:17 +08:00
parent 253667aece
commit 091a91c495

View File

@ -61,13 +61,13 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
//使用Redis判断消息发送是否大于5分钟 //使用Redis判断消息发送是否大于5分钟
Object cacheObject = redisService.getCacheObject(userRedisKey); Object cacheObject = redisService.getCacheObject(userRedisKey);
String currentTime; String currentTime;
String platformRedisKey = "PlatformMessageValidTime:" + userMessage.getTenantType() + ":" + userMessage.getTenantId() + ":" + loginUser.getUserType() + ":" + loginUser.getUsername();
if (cacheObject == null) { if (cacheObject == null) {
//设置当前时间 //设置当前时间
currentTime = DateUtil.getYyyyMmDdHhMmSs(); currentTime = DateUtil.getYyyyMmDdHhMmSs();
redisService.setCacheObject(userRedisKey, currentTime); redisService.setCacheObject(userRedisKey, currentTime);
redisService.expire(userRedisKey, 60 * 5); redisService.expire(userRedisKey, 60 * 5);
//设置平台RedisKey的有效时间保证双方时间数据同步 //设置平台RedisKey的有效时间保证双方时间数据同步
String platformRedisKey = "PlatformMessageValidTime:" + userMessage.getTenantType() + ":" + userMessage.getTenantId() + ":" + loginUser.getUserType() + ":" + loginUser.getUsername();
redisService.setCacheObject(platformRedisKey, currentTime); redisService.setCacheObject(platformRedisKey, currentTime);
redisService.expire(platformRedisKey, 60 * 5); redisService.expire(platformRedisKey, 60 * 5);
userMessage.setSendMessageTime(currentTime); userMessage.setSendMessageTime(currentTime);
@ -92,6 +92,7 @@ public class XhpcMessageBoardServiceImpl implements XhpcMessageBoardService {
} else { } else {
//reset redis key valid time //reset redis key valid time
redisService.expire(userRedisKey, 60 * 5); redisService.expire(userRedisKey, 60 * 5);
redisService.expire(platformRedisKey, 60 * 5);
currentTime = (String) cacheObject; currentTime = (String) cacheObject;
userMessage.setSendMessageTime(currentTime); userMessage.setSendMessageTime(currentTime);
//设置用户账号用户类型 //设置用户账号用户类型