public interface ICache
Modifier and Type | Interface and Description |
---|---|
static class |
ICache.NullClass
有时候需要放一个空对象到缓存中
|
Modifier and Type | Field and Description |
---|---|
static int |
MAX_EXPIRE_IN_LOCAL
在本地最大的过期时间,这样可以防止内存爆掉,单位:秒
|
static ICache.NullClass |
NULL_OBJ
用于临时存放于缓存中的对象,防止缓存null攻击
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
清空所有缓存
|
Serializable |
get(String key)
根据key获取value
|
<T> T |
get(String key,
Class<T> clazz)
根据key获取value
|
String |
getCacheName() |
Long |
getTimeToIdleSeconds() |
Long |
getTimeToLiveSeconds() |
Iterable<String> |
keys()
获取所有的key
|
void |
put(String key,
Serializable value)
将key value保存到缓存中
|
void |
putTemporary(String key,
Serializable value)
临时添加一个值,用于防止缓存穿透攻击
|
void |
remove(String key)
删除一个key
|
long |
ttl(String key)
对象还会存活多久。
|
static final ICache.NullClass NULL_OBJ
static final int MAX_EXPIRE_IN_LOCAL
String getCacheName()
void clear()
Serializable get(String key)
key
- void put(String key, Serializable value)
key
- value
- void remove(String key)
key
- void putTemporary(String key, Serializable value)
key
- value
- long ttl(String key)
Long getTimeToLiveSeconds()
Long getTimeToIdleSeconds()
Copyright © 2021. All rights reserved.