2、 Redis锁使用
@Async
@Scheduled(cron = "${outside_cron:0 0 23 * * ?}")
public void showTimer() throws ParseException {
String reqId = StringUtil.getShortUuid();
String objectId = IdUtil.objectId();
boolean getLock = redisTemplateUtil.setIfAbsent(objectId, reqId);
redisTemplateUtil.expireKey(objectId, 3000L, TimeUnit.SECONDS);
if (getLock) {
performTimingTask();
}
}
浙公网安备 33010602011771号