Class RedisTemplateClient
java.lang.Object
com.codeupsoft.component.redis.client.RedisTemplateClient
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong自减(Long类型).long自减指定值(Long类型).final <K> longdeleteCacheMapValue(String key, K... hashKeys) 删除Hash中的键.booleandeleteObject(String key) 删除单个对象.longdeleteObject(Collection<String> keys) 删除集合对象.boolean设置有效期.<T> List<T> getCacheList(String key) 获得缓存的List对象.<T> List<T> getCacheListOrLoad(String key, RedisCacheLoader<List<T>> redisCacheLoader) 获得缓存的List对象(带缓存加载).<T> List<T> getCacheListOrLoadWithLock(String key, RedisLoadWithLock<List<T>> redisLoadWithLock) 获得缓存的List对象(带锁的缓存加载).<K,V> Map <K, V> getCacheMap(String key) 获得缓存的Hash对象.<K,V> Map <K, V> getCacheMapOrLoad(String key, RedisCacheLoader<Map<K, V>> cacheLoader) 获得缓存的Hash对象(带缓存加载).<K,V> Map <K, V> getCacheMapOrLoadWithLock(String key, RedisLoadWithLock<Map<K, V>> redisLoadWithLock) 获得缓存的Hash对象(带锁的缓存加载).<K,V> V getCacheMapValue(String key, K hashKey) 获取Hash中的单个值.<T> TgetCacheObject(String key) 获得缓存的基本对象.<T> TgetCacheObjectOrLoad(String key, RedisCacheLoader<T> redisCacheLoader) 获得缓存的基本对象.<T> TgetCacheObjectOrLoadWithLock(String key, RedisLoadWithLock<T> redisLoadWithLock) 获得缓存的基本对象.<T> Collection<T> getCacheSet(String key) 获得缓存的Set对象.long获取有效期.<T> TgetListIndex(String key, long index) 根据索引获取List中的元素.longgetListSize(String key) 获取List的长度.longgetMapSize(String key) 获取Hash的大小.<K,V> List <V> getMultiCacheMapValue(String key, Collection<K> hashKeys) 获取Hash中多个键的值.longgetSetSize(String key) 获取Set的大小.boolean判断key是否存在.<K> boolean判断Hash中是否存在某个键.long自增(Long类型).double自增(Double类型).long自增指定值(Long类型).<K> doubleincrementMapValue(String key, K hashKey, double delta) Hash字段自增(Double类型).<K> longincrementMapValue(String key, K hashKey, long delta) Hash字段自增.<T> booleanisMemberOfSet(String key, T value) 判断Set中是否存在某个元素.<T> TleftPopList(String key) 从List左侧弹出元素.<T> longleftPushList(String key, T value) 向List左侧添加元素.<K,V> void putCacheMapValue(String key, K hashKey, V value) 向Hash中添加单个键值对.<T> TrandomMemberOfSet(String key) 随机获取Set中的元素.final <T> long移除Set中的元素.<T> TrightPopList(String key) 从List右侧弹出元素.<T> longrightPushList(String key, T value) 向List右侧添加元素.<T> longsetCacheList(String key, List<T> dataList) 缓存List数据.<T> voidsetCacheList(String key, List<T> dataList, long timeout, TimeUnit timeUnit) 缓存List数据(指定过期时间).<K,V> void setCacheMap(String key, Map<K, V> dataMap) 缓存Hash数据.<K,V> void setCacheMap(String key, Map<K, V> dataMap, long timeout, TimeUnit timeUnit) 缓存Hash数据(指定过期时间).<T> voidsetCacheObject(String key, T value) 缓存基本对象(无过期时间).<T> voidsetCacheObject(String key, T value, long timeout, TimeUnit timeUnit) 缓存基本对象(指定过期时间).final <T> longsetCacheSet(String key, long timeout, TimeUnit timeUnit, T... values) 缓存Set数据(指定过期时间).final <T> longsetCacheSet(String key, T... values) 缓存Set数据.
-
Constructor Details
-
RedisTemplateClient
public RedisTemplateClient()
-
-
Method Details
-
expire
-
getExpire
-
hasKey
-
setCacheObject
缓存基本对象(无过期时间).- Type Parameters:
T- 值类型- Parameters:
key- 缓存键value- 缓存值
-
setCacheObject
-
getCacheObject
获得缓存的基本对象.- Type Parameters:
T- 返回类型- Parameters:
key- 缓存键- Returns:
- 缓存值
-
getCacheObjectOrLoad
获得缓存的基本对象.- Type Parameters:
T- 返回类型- Parameters:
key- 缓存键redisCacheLoader- 缓存加载器- Returns:
- 缓存值
-
getCacheObjectOrLoadWithLock
获得缓存的基本对象.- Type Parameters:
T- 返回类型- Parameters:
key- 缓存键redisLoadWithLock- 缓存加载器- Returns:
- 缓存值
-
deleteObject
-
deleteObject
-
setCacheList
-
setCacheList
-
getCacheList
-
getCacheListOrLoad
获得缓存的List对象(带缓存加载).- Type Parameters:
T- 元素类型- Parameters:
key- 缓存键redisCacheLoader- 缓存加载器- Returns:
- 缓存的List对象
-
getCacheListOrLoadWithLock
public <T> List<T> getCacheListOrLoadWithLock(String key, RedisLoadWithLock<List<T>> redisLoadWithLock) 获得缓存的List对象(带锁的缓存加载).- Type Parameters:
T- 元素类型- Parameters:
key- 缓存键redisLoadWithLock- 缓存加载器- Returns:
- 缓存的List对象
-
leftPushList
向List左侧添加元素.- Type Parameters:
T- 元素类型- Parameters:
key- 缓存键value- 元素值- Returns:
- 添加后List的长度
-
rightPushList
向List右侧添加元素.- Type Parameters:
T- 元素类型- Parameters:
key- 缓存键value- 元素值- Returns:
- 添加后List的长度
-
leftPopList
从List左侧弹出元素.- Type Parameters:
T- 元素类型- Parameters:
key- 缓存键- Returns:
- 弹出的元素
-
rightPopList
从List右侧弹出元素.- Type Parameters:
T- 元素类型- Parameters:
key- 缓存键- Returns:
- 弹出的元素
-
getListSize
-
getListIndex
根据索引获取List中的元素.- Type Parameters:
T- 元素类型- Parameters:
key- 缓存键index- 索引- Returns:
- 元素值
-
setCacheSet
缓存Set数据.- Type Parameters:
T- 元素类型- Parameters:
key- 缓存键values- Set值- Returns:
- 添加的数量
-
setCacheSet
@SafeVarargs public final <T> long setCacheSet(String key, long timeout, TimeUnit timeUnit, T... values) 缓存Set数据(指定过期时间).- Type Parameters:
T- 元素类型- Parameters:
key- 缓存键timeout- 过期时间timeUnit- 时间单位values- Set值- Returns:
- 添加的数量
-
getCacheSet
获得缓存的Set对象.- Type Parameters:
T- 元素类型- Parameters:
key- 缓存键- Returns:
- Set对象
-
isMemberOfSet
判断Set中是否存在某个元素.- Type Parameters:
T- 元素类型- Parameters:
key- 缓存键value- 元素值- Returns:
- true=存在 false=不存在
-
getSetSize
-
removeSet
移除Set中的元素.- Type Parameters:
T- 元素类型- Parameters:
key- 缓存键values- 元素值- Returns:
- 移除的个数
-
randomMemberOfSet
随机获取Set中的元素.- Type Parameters:
T- 元素类型- Parameters:
key- 缓存键- Returns:
- 随机元素
-
setCacheMap
-
setCacheMap
-
putCacheMapValue
向Hash中添加单个键值对.- Type Parameters:
K- Hash键类型V- Hash值类型- Parameters:
key- 缓存键hashKey- Hash键value- Hash值
-
getCacheMap
-
getCacheMapOrLoad
获得缓存的Hash对象(带缓存加载).- Type Parameters:
K- Hash键类型V- Hash值类型- Parameters:
key- 缓存键cacheLoader- 缓存加载器- Returns:
- Hash对象
-
getCacheMapOrLoadWithLock
public <K,V> Map<K,V> getCacheMapOrLoadWithLock(String key, RedisLoadWithLock<Map<K, V>> redisLoadWithLock) 获得缓存的Hash对象(带锁的缓存加载).- Type Parameters:
K- Hash键类型V- Hash值类型- Parameters:
key- 缓存键redisLoadWithLock- 缓存加载器- Returns:
- Hash对象
-
getCacheMapValue
获取Hash中的单个值.- Type Parameters:
K- Hash键类型V- Hash值类型- Parameters:
key- 缓存键hashKey- Hash键- Returns:
- Hash值
-
getMultiCacheMapValue
获取Hash中多个键的值.- Type Parameters:
K- Hash键类型V- Hash值类型- Parameters:
key- 缓存键hashKeys- Hash键集合- Returns:
- Hash值列表
-
hasMapKey
判断Hash中是否存在某个键.- Type Parameters:
K- Hash键类型- Parameters:
key- 缓存键hashKey- Hash键- Returns:
- true=存在 false=不存在
-
getMapSize
-
deleteCacheMapValue
删除Hash中的键.- Type Parameters:
K- Hash键类型- Parameters:
key- 缓存键hashKeys- Hash键- Returns:
- 删除的数量
-
increment
-
increment
自增指定值(Long类型).- Parameters:
key- 缓存键delta- 增量- Returns:
- 自增后的值
-
increment
自增(Double类型).- Parameters:
key- 缓存键delta- 增量- Returns:
- 自增后的值
-
decrement
-
decrement
自减指定值(Long类型).- Parameters:
key- 缓存键delta- 减量- Returns:
- 自减后的值
-
incrementMapValue
Hash字段自增.- Type Parameters:
K- Hash键类型- Parameters:
key- 缓存键hashKey- Hash键delta- 增量- Returns:
- 自增后的值
-
incrementMapValue
Hash字段自增(Double类型).- Type Parameters:
K- Hash键类型- Parameters:
key- 缓存键hashKey- Hash键delta- 增量- Returns:
- 自增后的值
-