类 RedisServiceImpl

java.lang.Object
net.wenzuo.atom.redis.service.impl.RedisServiceImpl
所有已实现的接口:
RedisService

@ConditionalOnProperty(value="atom.redis.redis-service", matchIfMissing=true) @Service public class RedisServiceImpl extends Object implements RedisService
从以下版本开始:
2023-06-15
作者:
Catch
  • 构造器详细资料

    • RedisServiceImpl

      public RedisServiceImpl()
  • 方法详细资料

    • set

      public void set(String key, Object value)
      从接口复制的说明: RedisService
      保存 value
      指定者:
      set 在接口中 RedisService
      参数:
      key - 键
      value - 值
    • set

      public void set(String key, Object value, long timeout, TimeUnit unit)
      从接口复制的说明: RedisService
      保存 value 并设置过期时间
      指定者:
      set 在接口中 RedisService
      参数:
      key - 键
      value - 值
      timeout - 超时时间
      unit - 时间单位
    • set

      public void set(String key, Object value, Duration duration)
      从接口复制的说明: RedisService
      保存 value 并设置过期时间
      指定者:
      set 在接口中 RedisService
      参数:
      key - 键
      value - 值
      duration - 超时时间
    • setIfAbsent

      public Boolean setIfAbsent(String key, Object value)
      从接口复制的说明: RedisService
      如果 key 不存在则保存 value, 反之不保存
      指定者:
      setIfAbsent 在接口中 RedisService
      参数:
      key - 键
      value - 值
      返回:
      是否保存成功
    • setIfAbsent

      public Boolean setIfAbsent(String key, Object value, long timeout, TimeUnit unit)
      从接口复制的说明: RedisService
      如果 key 不存在则保存 value 并设置过期时间, 反之不保存
      指定者:
      setIfAbsent 在接口中 RedisService
      参数:
      key - 键
      value - 值
      timeout - 超时时间
      unit - 时间单位
      返回:
      是否保存成功
    • setIfAbsent

      public Boolean setIfAbsent(String key, Object value, Duration timeout)
      从接口复制的说明: RedisService
      如果 key 不存在则保存 value 并设置过期时间, 反之不保存
      指定者:
      setIfAbsent 在接口中 RedisService
      参数:
      key - 键
      value - 值
      timeout - 超时时间
      返回:
      是否保存成功
    • setIfPresent

      public Boolean setIfPresent(String key, Object value)
      从接口复制的说明: RedisService
      如果 key 存在则保存 value, 反之不保存
      指定者:
      setIfPresent 在接口中 RedisService
      参数:
      key - 键
      value - 值
      返回:
      是否保存成功
    • setIfPresent

      public Boolean setIfPresent(String key, Object value, long timeout, TimeUnit unit)
      从接口复制的说明: RedisService
      如果 key 存在则保存 value 并设置过期时间, 反之不保存
      指定者:
      setIfPresent 在接口中 RedisService
      参数:
      key - 键
      value - 值
      timeout - 超时时间
      unit - 时间单位
      返回:
      是否保存成功
    • setIfPresent

      public Boolean setIfPresent(String key, Object value, Duration timeout)
      从接口复制的说明: RedisService
      如果 key 存在则保存 value 并设置过期时间, 反之不保存
      指定者:
      setIfPresent 在接口中 RedisService
      参数:
      key - 键
      value - 值
      timeout - 超时时间
      返回:
      是否保存成功
    • multiSet

      public void multiSet(Map<String,?> map)
      从接口复制的说明: RedisService
      批量设置 key-value ,使用 redis mset 命令
      指定者:
      multiSet 在接口中 RedisService
      参数:
      map - key-value
    • multiSetIfAbsent

      public Boolean multiSetIfAbsent(Map<String,?> map)
      从接口复制的说明: RedisService
      批量设置 key-value ,使用 redis mset 命令, 如果 key 不存在则保存 value, 反之不保存
      指定者:
      multiSetIfAbsent 在接口中 RedisService
      参数:
      map - key-value
    • get

      public <T> T get(String key, Class<T> clazz)
      从接口复制的说明: RedisService
      获取 value
      指定者:
      get 在接口中 RedisService
      类型参数:
      T - 泛型
      参数:
      key - 键
      clazz - 类型
      返回:
    • get

      public <T> T get(String key, Class<?> wrapper, Class<?>... inners)
      从接口复制的说明: RedisService
      获取泛型 value

      如:List<Object> list = redisService.get(key, List.class, Object.class)

      指定者:
      get 在接口中 RedisService
      类型参数:
      T - 泛型
      参数:
      key - 键
      wrapper - 包装类
      inners - 内部类
      返回:
    • getAndDelete

      public <T> T getAndDelete(String key, Class<T> clazz)
      从接口复制的说明: RedisService
      获取 value 并删除 key
      指定者:
      getAndDelete 在接口中 RedisService
      类型参数:
      T - 泛型
      参数:
      key - 键
      clazz - 类型
      返回:
    • getAndDelete

      public <T> T getAndDelete(String key, Class<?> wrapper, Class<?>... inners)
      从接口复制的说明: RedisService
      获取泛型 value 并删除 key

      如:List<Object> list = redisService.getAndDelete(key, List.class, Object.class)

      指定者:
      getAndDelete 在接口中 RedisService
      类型参数:
      T - 泛型
      参数:
      key - 键
      wrapper - 包装类
      inners - 内部类
      返回:
    • getAndExpire

      public <T> T getAndExpire(String key, long timeout, TimeUnit unit, Class<T> clazz)
      从接口复制的说明: RedisService
      获取 value 并设置过期时间
      指定者:
      getAndExpire 在接口中 RedisService
      类型参数:
      T - 泛型
      参数:
      key - 键
      timeout - 超时时间
      unit - 时间单位
      clazz - 类型
      返回:
    • getAndExpire

      public <T> T getAndExpire(String key, long timeout, TimeUnit unit, Class<?> wrapper, Class<?>... inners)
      从接口复制的说明: RedisService
      获取泛型 value 并设置过期时间

      如:List<Object> list = redisService.getAndExpire(key, 1, TimeUnit.MINUTES, List.class, Object.class)

      指定者:
      getAndExpire 在接口中 RedisService
      类型参数:
      T - 泛型
      参数:
      key - 键
      timeout - 超时时间
      unit - 时间单位
      wrapper - 包装类
      inners - 内部类
      返回:
    • getAndExpire

      public <T> T getAndExpire(String key, Duration timeout, Class<T> clazz)
      从接口复制的说明: RedisService
      获取 value 并设置过期时间
      指定者:
      getAndExpire 在接口中 RedisService
      参数:
      key - 键
      timeout - 超时时间
      clazz - 类型
      返回:
    • getAndExpire

      public <T> T getAndExpire(String key, Duration timeout, Class<?> wrapper, Class<?>... inners)
      从接口复制的说明: RedisService
      获取泛型 value 并设置过期时间

      如:List<Object> list = redisService.getAndExpire(key, Duration.ofMinutes(1), List.class, Object.class)

      指定者:
      getAndExpire 在接口中 RedisService
      类型参数:
      T - 泛型
      参数:
      key - 键
      timeout - 超时时间
      wrapper - 包装类
      inners - 内部类
      返回:
    • getAndPersist

      public <T> T getAndPersist(String key, Class<T> clazz)
      从接口复制的说明: RedisService
      获取 value 并持久化 key, 此操作会移除 key 的过期时间
      指定者:
      getAndPersist 在接口中 RedisService
      类型参数:
      T - 泛型
      参数:
      key - 键
      clazz - 类型
      返回:
    • getAndPersist

      public <T> T getAndPersist(String key, Class<?> wrapper, Class<?>... inners)
      从接口复制的说明: RedisService
      获取泛型 value 并持久化 key, 此操作会移除 key 的过期时间

      如:List<Object> list = redisService.getAndPersist(key, List.class, Object.class)

      指定者:
      getAndPersist 在接口中 RedisService
      类型参数:
      T - 泛型
      参数:
      key - 键
      wrapper - 包装类
      inners - 内部类
      返回:
    • getAndSet

      public <T> T getAndSet(String key, Object value, Class<T> clazz)
      从接口复制的说明: RedisService
      保存 value 并返回旧的 value
      指定者:
      getAndSet 在接口中 RedisService
      类型参数:
      T - 泛型
      参数:
      key - 键
      value - 新值
      clazz - 类型
      返回:
      旧值
    • getAndSet

      public <T> T getAndSet(String key, Object value, Class<?> wrapper, Class<?>... inners)
      从接口复制的说明: RedisService
      保存泛型 value 并返回旧的 value

      如:List<Object> list = redisService.getAndSet(key, value, List.class, Object.class)

      指定者:
      getAndSet 在接口中 RedisService
      类型参数:
      T - 泛型
      参数:
      key - 键
      value - 新值
      wrapper - 包装类
      inners - 内部类
      返回:
      旧值
    • multiGet

      public <T> List<T> multiGet(Collection<String> keys, Class<T> clazz)
      从接口复制的说明: RedisService
      批量获取 value, 按键的顺序排列,不存在则用 null 填充
      指定者:
      multiGet 在接口中 RedisService
      参数:
      keys - 键集合
      返回:
      值集合
    • increment

      public Long increment(String key)
      从接口复制的说明: RedisService
      按步长为 1 递增 value
      指定者:
      increment 在接口中 RedisService
      参数:
      key - 键
      返回:
      递增后的值
    • increment

      public Long increment(String key, long delta)
      从接口复制的说明: RedisService
      按步长为 delta 递增 value
      指定者:
      increment 在接口中 RedisService
      参数:
      key - 键
      返回:
      递增后的值
    • increment

      public Double increment(String key, double delta)
      从接口复制的说明: RedisService
      按步长为 delta 递增 value
      指定者:
      increment 在接口中 RedisService
      参数:
      key - 键
      返回:
      递增后的值
    • decrement

      public Long decrement(String key)
      从接口复制的说明: RedisService
      按步长为 delta 递减 value
      指定者:
      decrement 在接口中 RedisService
      参数:
      key - 键
      返回:
      递减后的值
    • decrement

      public Long decrement(String key, long delta)
      从接口复制的说明: RedisService
      按步长为 delta 递减 value
      指定者:
      decrement 在接口中 RedisService
      参数:
      key - 键
      返回:
      递减后的值
    • hasKey

      public Boolean hasKey(String key)
      从接口复制的说明: RedisService
      是否存在 key
      指定者:
      hasKey 在接口中 RedisService
      参数:
      key - 键
      返回:
      是否存在
    • countExistingKeys

      public Long countExistingKeys(Collection<String> keys)
      从接口复制的说明: RedisService
      获取 key 集合中存在的 key 数量
      指定者:
      countExistingKeys 在接口中 RedisService
      参数:
      keys - 键集合
      返回:
      存在的 key 数量
    • delete

      public Boolean delete(String key)
      从接口复制的说明: RedisService
      删除 key
      指定者:
      delete 在接口中 RedisService
      参数:
      key - 键
      返回:
      是否删除成功
    • delete

      public Long delete(Collection<String> keys)
      从接口复制的说明: RedisService
      批量删除 key
      指定者:
      delete 在接口中 RedisService
      参数:
      keys - 键集合
      返回:
      删除的数量
    • unlink

      public Boolean unlink(String key)
      从接口复制的说明: RedisService
      从 key 空间中取消链接. 与 delete 不同,这里的内存回收是异步发生的
      指定者:
      unlink 在接口中 RedisService
      参数:
      key - 键
      返回:
      是否成功
    • unlink

      public Long unlink(Collection<String> keys)
      从接口复制的说明: RedisService
      批量从 key 空间中取消链接. 与 delete 不同,这里的内存回收是异步发生的
      指定者:
      unlink 在接口中 RedisService
      参数:
      keys - 键集合
      返回:
      取消链接的数量
    • keys

      public Set<String> keys(String pattern)
      从接口复制的说明: RedisService
      找到与模式匹配的所有键

      匹配示例:

      h?llo matches hello, hallo and hxllo

      h*llo matches hllo and heeeello

      h[ae]llo matches hello and hallo, but not hillo

      h[^e]llo matches hallo, hbllo, ... but not hello

      h[a-b]llo matches hallo and hbllo

      指定者:
      keys 在接口中 RedisService
      参数:
      pattern - 模式
      返回:
      匹配的所有键
    • rename

      public void rename(String oldKey, String newKey)
      从接口复制的说明: RedisService
      将 key 重命名为 newKey
      指定者:
      rename 在接口中 RedisService
      参数:
      oldKey - 旧键
      newKey - 新键
    • renameIfAbsent

      public Boolean renameIfAbsent(String oldKey, String newKey)
      从接口复制的说明: RedisService
      当 newKey 不存在时,将 key 重命名为 newKey
      指定者:
      renameIfAbsent 在接口中 RedisService
      参数:
      oldKey - 旧键
      newKey - 新键
      返回:
      是否重命名成功
    • expire

      public Boolean expire(String key, long timeout, TimeUnit unit)
      从接口复制的说明: RedisService
      设置 key 过期时间
      指定者:
      expire 在接口中 RedisService
      参数:
      key - 键
      timeout - 超时时间
      unit - 时间单位
      返回:
      是否设置成功
    • expire

      public Boolean expire(String key, Duration duration)
      从接口复制的说明: RedisService
      设置 key 过期时间
      指定者:
      expire 在接口中 RedisService
      参数:
      key - 键
      duration - 超时时间
      返回:
      是否设置成功
    • expireAt

      public Boolean expireAt(String key, Date date)
      从接口复制的说明: RedisService
      设置 key 在指定的时间过期
      指定者:
      expireAt 在接口中 RedisService
      参数:
      key - 键
      date - 指定的时间过期
      返回:
      是否设置成功
    • expireAt

      public Boolean expireAt(String key, Instant expireAt)
      从接口复制的说明: RedisService
      设置 key 在指定的时间过期
      指定者:
      expireAt 在接口中 RedisService
      参数:
      key - 键
      expireAt - 指定的时间过期
      返回:
      是否设置成功
    • persist

      public Boolean persist(String key)
      从接口复制的说明: RedisService
      设置 key 永不过期
      指定者:
      persist 在接口中 RedisService
      参数:
      key - 键
      返回:
      是否设置成功
    • getExpire

      public Long getExpire(String key)
      从接口复制的说明: RedisService
      获取过期时间, 单位: 秒
      指定者:
      getExpire 在接口中 RedisService
      参数:
      key - 键
      返回:
      过期时间, 单位: 秒
    • getExpire

      public Long getExpire(String key, TimeUnit timeUnit)
      从接口复制的说明: RedisService
      获取过期时间
      指定者:
      getExpire 在接口中 RedisService
      参数:
      key - 键
      timeUnit - 时间单位
      返回:
      过期时间