public class RedisGenericCache extends Object implements Level2Cache
Constructor and Description |
---|
RedisGenericCache(String namespace,
String region,
RedisClient client)
缓存构造
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
性能可能极其低下,谨慎使用
|
void |
evict(String... keys)
Remove items from the cache
|
boolean |
exists(String key)
判断缓存数据是否存在
|
List<byte[]> |
getBytes(Collection<String> keys)
同时读取多个 Key
|
byte[] |
getBytes(String key)
读取缓存数据字节数组
|
Collection<String> |
keys()
性能可能极其低下,谨慎使用
|
void |
setBytes(Map<String,byte[]> bytes)
同时设置多个数据
|
void |
setBytes(Map<String,byte[]> bytes,
long timeToLiveInSeconds)
批量设置带 TTL 的缓存数据
|
void |
setBytes(String key,
byte[] bytes)
设置缓存数据字节数组
|
void |
setBytes(String key,
byte[] bytes,
long timeToLiveInSeconds)
设置缓存数据字节数组(带有效期)
|
boolean |
supportTTL()
是否支持缓存 TTL 的设置
|
public RedisGenericCache(String namespace, String region, RedisClient client)
namespace
- 命名空间,用于在多个实例中避免 _key 的重叠region
- 缓存区域的名称client
- 缓存客户端接口public boolean supportTTL()
Level2Cache
supportTTL
in interface Level2Cache
public byte[] getBytes(String key)
Level2Cache
getBytes
in interface Level2Cache
key
- cache keypublic List<byte[]> getBytes(Collection<String> keys)
Level2Cache
getBytes
in interface Level2Cache
keys
- multiple cache keypublic void setBytes(String key, byte[] bytes)
Level2Cache
setBytes
in interface Level2Cache
key
- cache keybytes
- cache datapublic void setBytes(Map<String,byte[]> bytes)
Level2Cache
setBytes
in interface Level2Cache
bytes
- cache datapublic void setBytes(String key, byte[] bytes, long timeToLiveInSeconds)
Level2Cache
setBytes
in interface Level2Cache
key
- cache keybytes
- cache datatimeToLiveInSeconds
- cache ttlpublic void setBytes(Map<String,byte[]> bytes, long timeToLiveInSeconds)
Level2Cache
setBytes
in interface Level2Cache
bytes
- cache datatimeToLiveInSeconds
- cache ttlpublic boolean exists(String key)
Level2Cache
exists
in interface Cache
exists
in interface Level2Cache
key
- cache keypublic Collection<String> keys()
keys
in interface Cache
keys
in interface Level2Cache
public void evict(String... keys)
Level2Cache
evict
in interface Cache
evict
in interface Level2Cache
keys
- Cache keypublic void clear()
clear
in interface Cache
clear
in interface Level2Cache
Copyright © 2018. All rights reserved.