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
在接口中 Lock
InterruptedException
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException
tryLock
在接口中 Lock
InterruptedException
public Condition newCondition()
newCondition
在接口中 Lock
public String getLockSecretValue()
Copyright © 2024. All rights reserved.