类 RedisClient
- java.lang.Object
-
- xin.manong.weapon.base.redis.RedisClient
-
public class RedisClient extends Object
redis客户端- 作者:
- frankcl
-
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 static RedisClientbuildRedisClient(RedisClusterConfig config)构建集群模式redis客户端static RedisClientbuildRedisClient(RedisMasterSlaveConfig config)构建主从模式redis客户端static RedisClientbuildRedisClient(RedisSingleConfig config)构建单点模式redis客户端voidclose()关闭booleantryLock(String key, Long expiredSeconds)加锁booleantryReadLock(String key, Long expiredSeconds)加读锁booleantryWriteLock(String key, Long expiredSeconds)加写锁voidunlock(String key)解锁voidunLockRead(String key)解开读锁voidunLockWrite(String key)解开写锁
-
-
-
方法详细资料
-
close
public void close()
关闭
-
buildRedisClient
public static RedisClient buildRedisClient(RedisSingleConfig config)
构建单点模式redis客户端- 参数:
config- 配置信息- 返回:
- Redis客户端
-
buildRedisClient
public static RedisClient buildRedisClient(RedisClusterConfig config)
构建集群模式redis客户端- 参数:
config- 配置信息- 返回:
- redis客户端
-
buildRedisClient
public static RedisClient buildRedisClient(RedisMasterSlaveConfig config)
构建主从模式redis客户端- 参数:
config- 配置信息- 返回:
- redis客户端
-
tryLock
public boolean tryLock(String key, Long expiredSeconds)
加锁- 参数:
key- 锁keyexpiredSeconds- 过期时间(单位:秒),如果小于等于0,默认30秒- 返回:
- 加锁成功返回true,否则返回false
-
unlock
public void unlock(String key)
解锁- 参数:
key- 锁key
-
tryReadLock
public boolean tryReadLock(String key, Long expiredSeconds)
加读锁- 参数:
key- 锁keyexpiredSeconds- 过期时间(单位:秒),如果小于等于0,默认30秒- 返回:
- 加锁成功返回true,否则返回false
-
unLockRead
public void unLockRead(String key)
解开读锁- 参数:
key- 锁key
-
tryWriteLock
public boolean tryWriteLock(String key, Long expiredSeconds)
加写锁- 参数:
key- 锁keyexpiredSeconds- 过期时间(单位:秒),如果小于等于0,默认30秒- 返回:
- 加锁成功返回true,否则返回false
-
unLockWrite
public void unLockWrite(String key)
解开写锁- 参数:
key- 锁key
-
-