|
|
@@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
@Slf4j
|
|
|
public class RedissonUtils {
|
|
|
|
|
|
- private RedissonClient redissonClient;
|
|
|
+ private final RedissonClient redissonClient;
|
|
|
|
|
|
private static RedissonUtils redissonUtils;
|
|
|
|
|
|
@@ -278,10 +278,12 @@ public class RedissonUtils {
|
|
|
*/
|
|
|
public static void unlock(String lockKey) {
|
|
|
RLock lock = redissonUtils.redissonClient.getLock(lockKey);
|
|
|
- lock.unlock();
|
|
|
+ if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
|
|
+ lock.unlock();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public static Long getAtomicLong(String name,Long expired) {
|
|
|
+ public static Long getAtomicLong(String name, Long expired) {
|
|
|
RAtomicLong atomicLong = redissonUtils.redissonClient.getAtomicLong(name);
|
|
|
long number = atomicLong.incrementAndGet();
|
|
|
atomicLong.expire(expired <= 0 ? Duration.ofSeconds(DEFAULT_EXPIRED) : Duration.ofSeconds(expired));
|