...
|
...
|
@@ -80,12 +80,13 @@ public class RedisCache { |
|
|
//该活动的排序号加一
|
|
|
id = yhValueOperations.increment(SORT_ID_KEY + activityId, 1);
|
|
|
if (id == null || id.longValue() == 0) {
|
|
|
id = (long) (getMaxSort(activityId) + 1);
|
|
|
log.warn("getSortId from redis value is null with activityId is {}", activityId);
|
|
|
id = (long) (getMaxSort(activityId));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.warn("getSortId error", e);
|
|
|
log.error("getSortId from redis exception with activityId is {}", activityId, e);
|
|
|
//如果发生异常,则,再取数据库一次
|
|
|
id = (long) (getMaxSort(activityId) + 1);
|
|
|
id = (long) (getMaxSort(activityId));
|
|
|
}
|
|
|
return id.intValue();
|
|
|
}
|
...
|
...
|
@@ -95,11 +96,11 @@ public class RedisCache { |
|
|
* @param activityId
|
|
|
* @return
|
|
|
*/
|
|
|
private int getMaxSort(int activityId) {
|
|
|
private synchronized int getMaxSort(int activityId) {
|
|
|
int sortId = drawlineUserQueueDAO.selectMaxSortByActivityId(activityId);
|
|
|
int id = sortId + 1;
|
|
|
yHRedisTemplate.longExpire(SORT_ID_KEY + activityId, 6 * 30 * 24 * 3600, TimeUnit.SECONDS);
|
|
|
yhValueOperations.set(SORT_ID_KEY + activityId, String.valueOf(id));
|
|
|
yHRedisTemplate.longExpire(SORT_ID_KEY + activityId, 6 * 30 * 24 * 3600, TimeUnit.SECONDS);
|
|
|
return id;
|
|
|
}
|
|
|
|
...
|
...
|
|