public class RedisDistributedLock extends AbstractDistributedLock
| 限定符和类型 | 字段和说明 |
|---|---|
org.redisson.api.RedissonClient |
redissonClient |
LEASE_TIME, WAIT_TIME| 构造器和说明 |
|---|
RedisDistributedLock() |
| 限定符和类型 | 方法和说明 |
|---|---|
int |
decr(String key,
int delta)
递减
|
int |
incr(String key,
int delta)
递增
|
void |
initCount(String key,
int count)
初始红包数量
|
boolean |
lock(String key,
long waitTime,
long leaseTime)
加锁
|
boolean |
lock(String key,
long waitTime,
long leaseTime,
int tryCount,
long sleepTime)
加锁
|
void |
releaseLock(String key)
释放锁
|
void |
setRedissonClient(org.redisson.api.RedissonClient redissonClient) |
lockpublic void setRedissonClient(org.redisson.api.RedissonClient redissonClient)
public boolean lock(String key, long waitTime, long leaseTime)
DistributedLockkey - key值waitTime - 等待时间leaseTime - 最长时间public boolean lock(String key, long waitTime, long leaseTime, int tryCount, long sleepTime)
DistributedLockkey - key值waitTime - 等待时间leaseTime - 最长时间tryCount - 重试次数sleepTime - 重试休眠时长(毫秒)public void releaseLock(String key)
DistributedLockkey - key值public void initCount(String key, int count)
key - count - public int incr(String key, int delta)
key - key值delta - 要增加几(大于0)public int decr(String key, int delta)
key - 键delta - 要减少几(小于0)Copyright © 2021. All rights reserved.