Authored by DengXinFei

redis 操作修改

... ... @@ -72,7 +72,10 @@ public class RedisCache {
public int getSortId(int activityId) {
log.debug("getSortId with activityId is {}", activityId);
Long id = null;
//该活动的排序号加一
//该活动的排序号加一
if(!yHRedisTemplate.hasKey(SORT_ID_KEY + activityId)){
return getMaxSort(activityId);
}
id = yhValueOperations.increment(SORT_ID_KEY + activityId, 1);
if (id == null || id.longValue() == 0) {
log.warn("getSortId from redis value is null with activityId is {}", activityId);
... ... @@ -89,7 +92,7 @@ public class RedisCache {
private synchronized int getMaxSort(int activityId) {
int sortId = drawlineUserQueueDAO.selectMaxSortByActivityId(activityId);
int id = sortId + 1;
yhValueOperations.set(SORT_ID_KEY + activityId, String.valueOf(id));
yhValueOperations.setIfAbsent(SORT_ID_KEY + activityId, String.valueOf(id));
yHRedisTemplate.longExpire(SORT_ID_KEY + activityId, 6 * 30 * 24 * 3600, TimeUnit.SECONDS);
return id;
}
... ...