Class RedisCacheHelper
java.lang.Object
com.github.developframework.resource.spring.cache.RedisCacheHelper
redis缓存助手
- Author:
- qiushui on 2020-04-30.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <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) 读取值
-
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 readHashHV> (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-
-