public class RedisLock extends Object
Constructor and Description |
---|
RedisLock(redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool)
构造函数
|
RedisLock(redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool,
String name)
构造函数
|
RedisLock(String lockName)
构造函数
|
RedisLock(String host,
int port,
int timeout,
int poolsize,
String lockName)
构造函数
|
RedisLock(String host,
int port,
int timeout,
int poolsize,
String lockName,
String password)
构造函数
|
Modifier and Type | Method and Description |
---|---|
int |
getDbIndex()
获取当前选择的数据集
|
boolean |
lock(int lockExpireTime,
int timewait)
尝试加锁
超时时间 timewait 是尝试加锁的最长时间
|
boolean |
lock(String lockValue,
int lockExpireTime,
int timewait)
尝试加锁
超时时间 timewait 是尝试加锁的最长时间
|
void |
setDbIndex(int dbIndex)
选择当前数据集
|
boolean |
tryLock(int lockExpireTime)
尝试加锁
快速失败的方式
|
boolean |
tryLock(String lockValue,
int lockExpireTime)
尝试加锁
快速失败的方式
|
boolean |
unLock()
释放锁
|
boolean |
unLock(String lockValue)
释放锁
|
public RedisLock(String host, int port, int timeout, int poolsize, String lockName, String password)
host
- redis 服务地址port
- redis 服务端口timeout
- redis 连接超时时间poolsize
- redis 连接池的大小lockName
- 锁的键名password
- redis 服务密码public RedisLock(String host, int port, int timeout, int poolsize, String lockName)
host
- redis 服务地址port
- redis 服务端口timeout
- redis 连接超时时间poolsize
- redis 连接池的大小lockName
- 锁的键名称public RedisLock(String lockName)
lockName
- 锁的键名public RedisLock(redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool, String name)
jedisPool
- redis 连接池name
- 在 redis 中的 HashMap的名称public RedisLock(redis.clients.util.Pool<redis.clients.jedis.Jedis> jedisPool)
jedisPool
- redis 连接池public int getDbIndex()
public void setDbIndex(int dbIndex)
dbIndex
- 数据集序号public boolean tryLock(String lockValue, int lockExpireTime)
lockValue
- 锁的值lockExpireTime
- 锁的超时时间public boolean tryLock(int lockExpireTime)
lockExpireTime
- 超时时间public boolean lock(String lockValue, int lockExpireTime, int timewait)
lockValue
- 锁的名称lockExpireTime
- 锁的键值对的超时时间timewait
- 获取锁的等待时间, 单位: 毫秒public boolean lock(int lockExpireTime, int timewait)
lockExpireTime
- 锁的键值对的超时时间timewait
- 获取锁的等待时间, 单位: 毫秒public boolean unLock()
public boolean unLock(String lockValue)
lockValue
- 锁的名称Copyright © 2020 Voovan. All rights reserved.