public class LRUCache extends LinkedHashMap<String,net.sohelp.boot.admin.core.db.cache.LRUCache.ExpireNode<Object>>
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| 构造器和说明 |
|---|
LRUCache(int capacity,
long expire)
构造一个默认的SQL缓存实例,使用LRU缓存策略。
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
delete(String name)
删除指定命名空间下的所有缓存项。
|
Object |
get(String name,
String key)
获取缓存中的数据,若不存在或已过期则返回null。
|
void |
put(String name,
String key,
Object value)
向缓存中添加数据,默认使用全局过期时间。
|
void |
put(String name,
String key,
Object value,
long ttl)
向缓存中添加数据,可指定自定义过期时间。
|
protected boolean |
removeEldestEntry(Map.Entry<String,net.sohelp.boot.admin.core.db.cache.LRUCache.ExpireNode<Object>> eldest)
当缓存大小超过设定容量时触发移除最老元素的操作。
|
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, replaceAll, valuesclone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeequals, hashCode, toStringcompute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizepublic LRUCache(int capacity,
long expire)
capacity - 缓存的最大容量expire - 缓存项的过期时间(单位:毫秒)public void put(String name, String key, Object value)
name - 命名空间名称key - 数据键value - 数据值public void put(String name, String key, Object value, long ttl)
name - 命名空间名称key - 数据键value - 数据值ttl - 自定义过期时间(单位:毫秒)public Object get(String name, String key)
name - 命名空间名称key - 数据键public void delete(String name)
name - 命名空间名称protected boolean removeEldestEntry(Map.Entry<String,net.sohelp.boot.admin.core.db.cache.LRUCache.ExpireNode<Object>> eldest)
removeEldestEntry 在类中 LinkedHashMap<String,net.sohelp.boot.admin.core.db.cache.LRUCache.ExpireNode<Object>>eldest - 最近最少使用的条目Copyright © 2026. All rights reserved.