public class RedisTemplateSimpleDistributedLock extends Object implements Lock
| 构造器和说明 |
|---|
RedisTemplateSimpleDistributedLock(org.springframework.data.redis.core.StringRedisTemplate redisTemplate,
int leaseMilliseconds) |
RedisTemplateSimpleDistributedLock(org.springframework.data.redis.core.StringRedisTemplate redisTemplate,
String key,
int leaseMilliseconds) |
| 限定符和类型 | 方法和说明 |
|---|---|
String |
getLockSecretValue()
获取当前锁的值
return 返回null意味着没有加锁, 但是返回非null值并不以为着当前加锁成功(redis中key可能自动过期)
|
void |
lock() |
void |
lockInterruptibly() |
Condition |
newCondition() |
boolean |
tryLock() |
boolean |
tryLock(long time,
TimeUnit unit) |
void |
unlock() |
public RedisTemplateSimpleDistributedLock(org.springframework.data.redis.core.StringRedisTemplate redisTemplate,
int leaseMilliseconds)
public RedisTemplateSimpleDistributedLock(org.springframework.data.redis.core.StringRedisTemplate redisTemplate,
String key,
int leaseMilliseconds)
public void lockInterruptibly()
throws InterruptedException
lockInterruptibly 在接口中 LockInterruptedExceptionpublic boolean tryLock(long time,
TimeUnit unit)
throws InterruptedException
tryLock 在接口中 LockInterruptedExceptionpublic Condition newCondition()
newCondition 在接口中 Lockpublic String getLockSecretValue()
Copyright © 2026. All rights reserved.