public final class KeyHandler extends Object implements RedisHandler
Modifier and Type | Method and Description |
---|---|
Long |
count()
当前数据库中键的数量
|
byte[] |
dump(String key)
获取序列化字符串
|
byte[] |
dumpAsObj(String key)
获取序列化对象
|
Boolean |
expire(String key,
long timeout,
TimeUnit timeUnit)
设置字符串过期时间
|
Boolean |
expireAsObj(String key,
long timeout,
TimeUnit timeUnit)
设置对象过期时间
|
Boolean |
expireAt(String key,
Date date)
设置字符串过期时间
|
Boolean |
expireAtAsObj(String key,
Date date)
设置对象过期时间
|
Long |
getExpire(String key,
TimeUnit timeUnit)
获取字符串过期时间
|
Long |
getExpireAsObj(String key,
TimeUnit timeUnit)
获取对象过期时间
|
org.springframework.data.redis.core.RedisTemplate<String,Object> |
getRedisTemplate()
获取spring redis模板
|
org.springframework.data.redis.core.StringRedisTemplate |
getStringRedisTemplate()
获取spring string redis模板
|
org.springframework.data.redis.connection.DataType |
getType(String key)
获取字符串存储数据类型
|
org.springframework.data.redis.connection.DataType |
getTypeAsObj(String key)
获取对象存储数据类型
|
Boolean |
hasKey(String key)
是否存在key(字符串)
|
Boolean |
hasKeyAsObj(String key)
是否存在key(对象)
|
Set<String> |
keys(String pattern)
字符串的键集合
|
Set<String> |
keysAsObj(String pattern)
对象的键集合
|
Long |
keysCount(String... keys)
字符串的键存在的数量
|
Long |
keysCountAsObj(String... keys)
对象的键存在的数量
|
Boolean |
move(int dbIndex,
String key)
移动字符串到指定数据库
|
Boolean |
moveAsObj(int dbIndex,
String key)
移动对象到指定数据库
|
Boolean |
persist(String key)
持久化字符串
|
Boolean |
persistAsObj(String key)
持久化对象
|
String |
randomKey()
获取字符串随机key
|
String |
randomKeyAsObj()
获取对象随机key
|
Long |
remove(String... keys)
移除字符串key
|
Long |
removeAsObj(String... keys)
移除对象key
|
void |
rename(String oldKey,
String newKey)
重命名字符串key
|
void |
renameAsObj(String oldKey,
String newKey)
重命名对象key
|
Boolean |
renameAsObjIfAbsent(String oldKey,
String newKey)
重命名对象key如果存在
|
Boolean |
renameIfAbsent(String oldKey,
String newKey)
重命名字符串key如果存在
|
void |
restore(String key,
byte[] value,
Long timeout,
TimeUnit unit,
boolean replace)
序列化存储字符串
|
void |
restoreAsObj(String key,
byte[] value,
Long timeout,
TimeUnit unit,
boolean replace)
序列化存储对象
|
List<String> |
sort(org.springframework.data.redis.core.query.SortQuery<String> query)
排序(字符串)
|
List<String> |
sort(String key)
排序(字符串)
|
Long |
sortAndCover(org.springframework.data.redis.core.query.SortQuery<String> query)
排序并覆盖(字符串)
|
Long |
sortAndCover(String key)
排序并覆盖(字符串)
|
Long |
sortAndCoverAsObj(org.springframework.data.redis.core.query.SortQuery<String> query)
排序并覆盖(对象)
|
Long |
sortAndCoverAsObj(String key)
排序并覆盖(对象)
|
Long |
sortAndStore(org.springframework.data.redis.core.query.SortQuery<String> query,
String storeKey)
排序并保存(字符串)
|
Long |
sortAndStore(String key,
String storeKey)
排序并保存(字符串)
|
Long |
sortAndStoreAsObj(org.springframework.data.redis.core.query.SortQuery<String> query,
String storeKey)
排序并保存(对象)
|
Long |
sortAndStoreAsObj(String key,
String storeKey)
排序并保存(对象)
|
List |
sortAsObj(org.springframework.data.redis.core.query.SortQuery<String> query)
排序(对象)
|
List |
sortAsObj(String key)
排序(对象)
|
Long |
touch(String... keys)
字符串最后访问时间更新
|
Long |
touchAsObj(String... keys)
对象最后访问时间更新
|
Long |
unlink(String... keys)
移除存在的字符串key
|
Long |
unlinkAsObj(String... keys)
移除存在的对象key
|
public Boolean hasKeyAsObj(String key)
key
- 键public Boolean hasKey(String key)
key
- 键public Long removeAsObj(String... keys)
keys
- 键public Long remove(String... keys)
keys
- 键public Long unlinkAsObj(String... keys)
keys
- 键public Long unlink(String... keys)
keys
- 键public Boolean expireAsObj(String key, long timeout, TimeUnit timeUnit)
key
- 键timeout
- 过期时间timeUnit
- 时间单位public Boolean expire(String key, long timeout, TimeUnit timeUnit)
key
- 键timeout
- 过期时间timeUnit
- 时间单位public Boolean expireAtAsObj(String key, Date date)
key
- 键date
- 过期时间public Boolean expireAt(String key, Date date)
key
- 键date
- 过期时间public Long getExpireAsObj(String key, TimeUnit timeUnit)
key
- 键timeUnit
- 时间单位public Long getExpire(String key, TimeUnit timeUnit)
key
- 键timeUnit
- 时间单位public org.springframework.data.redis.connection.DataType getTypeAsObj(String key)
key
- 键public org.springframework.data.redis.connection.DataType getType(String key)
key
- 键public Set<String> keysAsObj(String pattern)
pattern
- 键规则public Set<String> keys(String pattern)
pattern
- 键规则public Long keysCountAsObj(String... keys)
keys
- 键public Long keysCount(String... keys)
keys
- 键public String randomKeyAsObj()
public String randomKey()
public void renameAsObj(String oldKey, String newKey)
oldKey
- 旧keynewKey
- 新keypublic void rename(String oldKey, String newKey)
oldKey
- 旧keynewKey
- 新keypublic Boolean renameAsObjIfAbsent(String oldKey, String newKey)
oldKey
- 旧keynewKey
- 新keypublic Boolean renameIfAbsent(String oldKey, String newKey)
oldKey
- 旧keynewKey
- 新keypublic Boolean persistAsObj(String key)
key
- 键public Boolean persist(String key)
key
- 键public Boolean moveAsObj(int dbIndex, String key)
dbIndex
- 数据库索引key
- 键public Boolean move(int dbIndex, String key)
dbIndex
- 数据库索引key
- 键public Long count()
public byte[] dumpAsObj(String key)
key
- 键public byte[] dump(String key)
key
- 键public void restoreAsObj(String key, byte[] value, Long timeout, TimeUnit unit, boolean replace)
key
- 键value
- 对象字节timeout
- 过期时间unit
- 单位replace
- 是否替换public void restore(String key, byte[] value, Long timeout, TimeUnit unit, boolean replace)
key
- 键value
- 字符串字节timeout
- 过期时间unit
- 单位replace
- 是否替换public Long touchAsObj(String... keys)
keys
- 键public Long touch(String... keys)
keys
- 键public List sortAsObj(String key)
key
- 键public List<String> sort(String key)
key
- 键public Long sortAndCoverAsObj(String key)
key
- 键public Long sortAndCover(String key)
key
- 键public Long sortAndStoreAsObj(String key, String storeKey)
key
- 键storeKey
- 保存键public Long sortAndStore(String key, String storeKey)
key
- 键storeKey
- 保存键public List sortAsObj(org.springframework.data.redis.core.query.SortQuery<String> query)
query
- 排序对象public List<String> sort(org.springframework.data.redis.core.query.SortQuery<String> query)
query
- 排序对象public Long sortAndCoverAsObj(org.springframework.data.redis.core.query.SortQuery<String> query)
query
- 排序对象public Long sortAndCover(org.springframework.data.redis.core.query.SortQuery<String> query)
query
- 排序对象public Long sortAndStoreAsObj(org.springframework.data.redis.core.query.SortQuery<String> query, String storeKey)
query
- 排序对象storeKey
- 保存键public Long sortAndStore(org.springframework.data.redis.core.query.SortQuery<String> query, String storeKey)
query
- 排序对象storeKey
- 保存键public org.springframework.data.redis.core.RedisTemplate<String,Object> getRedisTemplate()
public org.springframework.data.redis.core.StringRedisTemplate getStringRedisTemplate()
Copyright © 2019. All rights reserved.