-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request
Description
boolean isSuccess = redisTemplate.opsForValue().setIfAbsent(businessKey, uniqueValue);
if (!isSuccess) {
throw new Exception("You can't do it,because another has get the lock =-=");
}
redisTemplate.expire(businessKey, annotation.lockTime(), TimeUnit.SECONDS);
这块redis操作,不是原子的,如果在设置过期时间前,突然宕机了,则加锁后的key将长时间存在,
应该用
Boolean setIfAbsent(K key, V value, long timeout, TimeUnit unit);
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request