类 RedisClient


  • public class RedisClient
    extends Object
    redis客户端
    作者:
    frankcl
    • 方法详细资料

      • 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客户端
      • buildRedisClient

        public static RedisClient buildRedisClient​(RedisSentinelConfig config)
        构建哨兵模式RedisClient
        参数:
        config - 配置信息
        返回:
        redis客户端
      • tryLock

        public boolean tryLock​(String key,
                               Long expiredSeconds)
        加锁
        参数:
        key - 锁key
        expiredSeconds - 过期时间(单位:秒),如果小于等于0,默认30秒
        返回:
        加锁成功返回true,否则返回false
      • unlock

        public void unlock​(String key)
        解锁
        参数:
        key - 锁key
      • tryReadLock

        public boolean tryReadLock​(String key,
                                   Long expiredSeconds)
        加读锁
        参数:
        key - 锁key
        expiredSeconds - 过期时间(单位:秒),如果小于等于0,默认30秒
        返回:
        加锁成功返回true,否则返回false
      • unLockRead

        public void unLockRead​(String key)
        解开读锁
        参数:
        key - 锁key
      • tryWriteLock

        public boolean tryWriteLock​(String key,
                                    Long expiredSeconds)
        加写锁
        参数:
        key - 锁key
        expiredSeconds - 过期时间(单位:秒),如果小于等于0,默认30秒
        返回:
        加锁成功返回true,否则返回false
      • unLockWrite

        public void unLockWrite​(String key)
        解开写锁
        参数:
        key - 锁key
      • buildTransaction

        public org.redisson.api.RTransaction buildTransaction()
        构建事务
        返回:
        事务
      • buildTransaction

        public org.redisson.api.RTransaction buildTransaction​(org.redisson.api.TransactionOptions options)
        构建事务
        参数:
        options - 事务选项
        返回:
        事务
      • getRateLimiter

        public org.redisson.api.RRateLimiter getRateLimiter​(String key)
        获取限速器
        参数:
        key - 限速器key
        返回:
        限速器实例
      • getMemoryInfo

        public RedisMemory getMemoryInfo()
        获取内存使用情况
        返回:
        内存使用情况,无法获取返回null
      • getRedissonClient

        public org.redisson.api.RedissonClient getRedissonClient()
        获取RedissonClient
        返回:
        RedissonClient实例