Class RedisCacheHelper

java.lang.Object
com.github.developframework.resource.spring.cache.RedisCacheHelper

public final class RedisCacheHelper extends Object
redis缓存助手
Author:
qiushui on 2020-04-30.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <K, V> void
    deleteKeys(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K pattern)
    批量删除
    static <K, V> boolean
    hasKey(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key)
    判断是否有键
    static <K, V> boolean
    listEmpty(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key)
    列表是否为空
    static <K, V> develop.toolkit.base.struct.KeyValuePair<Long,V>
    listFind(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key, Predicate<V> predicate)
    列表匹配查询匹配单个
    static <K, V> develop.toolkit.base.struct.KeyValuePairs<Long,V>
    listFindAll(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key, Predicate<V> predicate)
    列表匹配查询
    static <K, V> boolean
    listNotEmpty(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key)
    列表是否有值
    static <K, V> long
    listSize(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key)
    获取列表长度
    static <H, HK, HV> HV
    readHash(org.springframework.data.redis.core.RedisTemplate<H,HV> redisTemplate, H key, HK hashKey, Supplier<HV> defaultSupplier)
    读取Hash值
    static <K, V> V
    readValue(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key, Duration timeout, Supplier<V> defaultSupplier)
    读取值

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RedisCacheHelper

      public RedisCacheHelper()
  • Method Details

    • hasKey

      public static <K, V> boolean hasKey(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key)
      判断是否有键
      Type Parameters:
      K -
      V -
      Parameters:
      redisTemplate -
      key -
      Returns:
    • listSize

      public static <K, V> long listSize(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key)
      获取列表长度
      Type Parameters:
      K -
      V -
      Parameters:
      redisTemplate -
      key -
      Returns:
    • listNotEmpty

      public static <K, V> boolean listNotEmpty(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key)
      列表是否有值
      Type Parameters:
      K -
      V -
      Parameters:
      redisTemplate -
      key -
      Returns:
    • listEmpty

      public static <K, V> boolean listEmpty(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key)
      列表是否为空
      Type Parameters:
      K -
      V -
      Parameters:
      redisTemplate -
      key -
      Returns:
    • listFind

      public static <K, V> develop.toolkit.base.struct.KeyValuePair<Long,V> listFind(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key, Predicate<V> predicate)
      列表匹配查询匹配单个
      Type Parameters:
      K -
      V -
      Parameters:
      redisTemplate -
      key -
      predicate -
      Returns:
    • listFindAll

      public static <K, V> develop.toolkit.base.struct.KeyValuePairs<Long,V> listFindAll(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key, Predicate<V> predicate)
      列表匹配查询
      Type Parameters:
      K -
      V -
      Parameters:
      redisTemplate -
      key -
      predicate -
      Returns:
    • readValue

      public static <K, V> V readValue(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K key, Duration timeout, Supplier<V> defaultSupplier)
      读取值
      Type Parameters:
      K -
      V -
      Parameters:
      redisTemplate -
      defaultSupplier -
      key -
      Returns:
    • readHash

      public static <H, HK, HV> HV readHash(org.springframework.data.redis.core.RedisTemplate<H,HV> redisTemplate, H key, HK hashKey, Supplier<HV> defaultSupplier)
      读取Hash值
      Type Parameters:
      H -
      HK -
      HV -
      Parameters:
      redisTemplate -
      key -
      hashKey -
      defaultSupplier -
      Returns:
    • deleteKeys

      public static <K, V> void deleteKeys(org.springframework.data.redis.core.RedisTemplate<K,V> redisTemplate, K pattern)
      批量删除
      Type Parameters:
      K -
      V -
      Parameters:
      redisTemplate -
      pattern -