@Component public class RedisService extends Object implements CacheService
| 限定符和类型 | 字段和说明 |
|---|---|
org.springframework.data.redis.core.RedisTemplate |
redisTemplate |
| 构造器和说明 |
|---|
RedisService() |
| 限定符和类型 | 方法和说明 |
|---|---|
Long |
decrement(ICacheKey key,
String keyParams)
减1
|
long |
deleteObject(Collection collection)
删除集合对象
|
boolean |
deleteObject(ICacheKey key,
Object... keyParams)
删除单个对象
|
boolean |
deleteObject(String key)
删除单个对象
|
boolean |
expire(ICacheKey key,
Object... keyParams)
设置有效时间
|
boolean |
expire(String key,
long timeout)
设置有效时间
|
boolean |
expire(String key,
long timeout,
TimeUnit unit)
设置有效时间
|
<T> List<T> |
getCacheList(String key)
获得缓存的list对象
|
<T> Map<String,T> |
getCacheMap(String key)
获得缓存的Map
|
<T> T |
getCacheMapValue(String key,
String hKey)
获取Hash中的数据
|
<T> T |
getCacheObject(ICacheKey key,
Object... keyParams)
获得缓存的基本对象。
|
<T> T |
getCacheObject(String key)
获得缓存的基本对象。
|
<T> Set<T> |
getCacheSet(String key)
获得缓存的set
|
<T> List<T> |
getMultiCacheMapValue(String key,
Collection<Object> hKeys)
获取多个Hash中的数据
|
Collection<String> |
keys(String pattern)
获得缓存的基本对象列表
|
HashOps |
opsForHash() |
KeyOps |
opsForKey() |
ListOps |
opsForList() |
ValueOps |
opsForValue() |
<T> long |
setCacheList(String key,
List<T> dataList)
缓存List数据
|
<T> void |
setCacheMap(String key,
Map<String,T> dataMap)
缓存Map
|
<T> void |
setCacheMapValue(String key,
String hKey,
T value)
往Hash中存入数据
|
<T> void |
setCacheObject(ICacheKey key,
T value,
Object... keyParams)
缓存基本的对象,Integer、String、实体类等
|
<T> void |
setCacheObject(String key,
T value)
缓存基本的对象,Integer、String、实体类等
|
<T> void |
setCacheObject(String key,
T value,
Long timeout,
TimeUnit timeUnit)
缓存基本的对象,Integer、String、实体类等
|
<T> org.springframework.data.redis.core.BoundSetOperations<String,T> |
setCacheSet(String key,
Set<T> dataSet)
缓存Set
|
public KeyOps opsForKey()
opsForKey 在接口中 CacheServicepublic ListOps opsForList()
opsForList 在接口中 CacheServicepublic ValueOps opsForValue()
opsForValue 在接口中 CacheServicepublic HashOps opsForHash()
opsForHash 在接口中 CacheServicepublic <T> void setCacheObject(String key, T value)
key - 缓存的键值value - 缓存的值public <T> void setCacheObject(ICacheKey key, T value, Object... keyParams)
key - 缓存keyvalue - 缓存的值keyParams - key参数public <T> void setCacheObject(String key, T value, Long timeout, TimeUnit timeUnit)
key - 缓存的键值value - 缓存的值timeout - 时间timeUnit - 时间颗粒度public Long decrement(ICacheKey key, String keyParams)
key - 缓存键keyParams - key参数public boolean expire(String key, long timeout)
key - Redis键timeout - 超时时间public boolean expire(ICacheKey key, Object... keyParams)
key - Redis键keyParams - key的参数public boolean expire(String key, long timeout, TimeUnit unit)
key - Redis键timeout - 超时时间unit - 时间单位public <T> T getCacheObject(String key)
key - 缓存键值public <T> T getCacheObject(ICacheKey key, Object... keyParams)
key - keykeyParams - key参数public boolean deleteObject(String key)
key - public boolean deleteObject(ICacheKey key, Object... keyParams)
key - keyParams - key参数public long deleteObject(Collection collection)
collection - 多个对象public <T> long setCacheList(String key, List<T> dataList)
key - 缓存的键值dataList - 待缓存的List数据public <T> org.springframework.data.redis.core.BoundSetOperations<String,T> setCacheSet(String key, Set<T> dataSet)
key - 缓存键值dataSet - 缓存的数据public <T> void setCacheMap(String key, Map<String,T> dataMap)
key - dataMap - public <T> void setCacheMapValue(String key, String hKey, T value)
key - Redis键hKey - Hash键value - 值public <T> T getCacheMapValue(String key, String hKey)
key - Redis键hKey - Hash键public <T> List<T> getMultiCacheMapValue(String key, Collection<Object> hKeys)
key - Redis键hKeys - Hash键集合public Collection<String> keys(String pattern)
pattern - 字符串前缀Copyright © 2022. All rights reserved.