public class ExpireCache extends ConcurrentHashMap<String,ExpireCacheData<Object>>
ConcurrentHashMap.KeySetView<K,V>AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| 限定符和类型 | 字段和说明 |
|---|---|
static ExpireCache |
CACHE
单例,外界一般调用该对象的方法
|
| 构造器和说明 |
|---|
ExpireCache() |
| 限定符和类型 | 方法和说明 |
|---|---|
Object |
get(String key)
获取缓存中的数据
|
<T> T |
get(String key,
Class<T> clz)
获取缓存中的数据(避免强类型转换的麻烦)
|
void |
put(String key,
Object data,
int expire)
设置 key 与 cache
|
void |
put(String key,
Object data,
int expire,
java.util.function.Supplier<Object> load)
设置 key 与 cache
|
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, get, getOrDefault, hashCode, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, valuesclonepublic static final ExpireCache CACHE
public <T> T get(String key, Class<T> clz)
T - 缓存的类型key - 缓存 KEYclz - 缓存的类型public void put(String key, Object data, int expire)
key - 缓存 KEYdata - 要缓存的数据expire - 过期时间,单位是秒public void put(String key, Object data, int expire, java.util.function.Supplier<Object> load)
key - 缓存 KEYdata - 要缓存的数据expire - 过期时间,单位是秒load - 数据装载器,如果缓存中没有数据或者已经过期,则调用数据装载器加载最新的数据并且加入缓存,并返回Copyright © 2013–2021 AJAXJS. All rights reserved.