Authored by ping

update

... ... @@ -53,9 +53,13 @@ public class RedisCache {
int maxId = 0;
//遍历所有活动,设置到redis
for (DrawlineActivity act : activityList) {
maxId = drawlineUserQueueDAO.selectMaxSortByActivityId(act.getId());
yhValueOperations.setIfAbsent(SORT_ID_KEY + act.getId().intValue(), String.valueOf(maxId));
yHRedisTemplate.longExpire(SORT_ID_KEY + act.getId().intValue(), 6 * 30 * 24 * 3600, TimeUnit.SECONDS);
try {
maxId = drawlineUserQueueDAO.selectMaxSortByActivityId(act.getId());
yhValueOperations.setIfAbsent(SORT_ID_KEY + act.getId().intValue(), String.valueOf(maxId));
yHRedisTemplate.longExpire(SORT_ID_KEY + act.getId().intValue(), 6 * 30 * 24 * 3600, TimeUnit.SECONDS);
} catch (Exception e) {
log.error("init activity sort error with activityId {}", act.getId(), e);
}
}
}
... ... @@ -69,6 +73,10 @@ public class RedisCache {
log.debug("getSortId with activityId is {}", activityId);
Long id = null;
try {
//如果redis中没有该活动的key,则从数据库中取出
// if (!yHRedisTemplate.hasKey(SORT_ID_KEY + activityId)) {
// id = (long)getMaxSort(activityId);
// }
//该活动的排序号加一
id = yhValueOperations.increment(SORT_ID_KEY + activityId, 1);
if (id == null || id.longValue() == 0) {
... ... @@ -90,6 +98,7 @@ public class RedisCache {
private 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));
return id;
}
... ...
... ... @@ -28,7 +28,7 @@ public class SendUserAwardTimer {
@Autowired
private ILuckyUserService luckyUserService;
@Scheduled(fixedDelay = 300 * 1000)
// @Scheduled(fixedDelay = 300 * 1000)
public void sendAwardToLuckyUser() {
DynamicStringProperty taskHost = DynamicPropertyFactory.getInstance().getStringProperty("execute.timetask.host", "192.168.90.9");
String localIP = LocalIp.getLocalIp();
... ...