Class LruFeatureStore
java.lang.Object
cloud.opencode.base.feature.store.LruFeatureStore
- All Implemented Interfaces:
FeatureStore
LRU Feature Store
LRU功能存储
In-memory store with LRU eviction policy.
带有LRU淘汰策略的内存存储。
Features | 主要功能:
- LRU eviction - LRU淘汰
- Capacity limit - 容量限制
- Thread-safe - 线程安全
Usage Examples | 使用示例:
// Store with max 100 features
FeatureStore store = new LruFeatureStore(100);
// When capacity exceeded, least recently used features are evicted
for (int i = 0; i < 150; i++) {
store.save(Feature.builder("feature-" + i).build());
}
// Only 100 most recent features remain
- Since:
- JDK 25, opencode-base-feature V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all features 清除所有功能intcount()Get the count of features 获取功能数量booleanDelete a feature 删除功能booleanCheck if a feature exists 检查功能是否存在Find a feature by key 根据键查找功能findAll()Find all features 查找所有功能intGet the maximum size 获取最大大小voidSave a feature 保存功能
-
Constructor Details
-
LruFeatureStore
public LruFeatureStore(int maxSize) Create LRU store with max size 创建具有最大大小的LRU存储- Parameters:
maxSize- the maximum number of features | 最大功能数
-
-
Method Details
-
save
Description copied from interface:FeatureStoreSave a feature 保存功能- Specified by:
savein interfaceFeatureStore- Parameters:
feature- the feature to save | 要保存的功能
-
find
Description copied from interface:FeatureStoreFind a feature by key 根据键查找功能- Specified by:
findin interfaceFeatureStore- Parameters:
key- the feature key | 功能键- Returns:
- optional containing feature if found | 如果找到则包含功能的Optional
-
findAll
Description copied from interface:FeatureStoreFind all features 查找所有功能- Specified by:
findAllin interfaceFeatureStore- Returns:
- list of all features | 所有功能的列表
-
delete
Description copied from interface:FeatureStoreDelete a feature 删除功能- Specified by:
deletein interfaceFeatureStore- Parameters:
key- the feature key | 功能键- Returns:
- true if deleted | 如果删除成功返回true
-
exists
Description copied from interface:FeatureStoreCheck if a feature exists 检查功能是否存在- Specified by:
existsin interfaceFeatureStore- Parameters:
key- the feature key | 功能键- Returns:
- true if exists | 如果存在返回true
-
count
public int count()Description copied from interface:FeatureStoreGet the count of features 获取功能数量- Specified by:
countin interfaceFeatureStore- Returns:
- feature count | 功能数量
-
clear
public void clear()Description copied from interface:FeatureStoreClear all features 清除所有功能- Specified by:
clearin interfaceFeatureStore
-
getMaxSize
public int getMaxSize()Get the maximum size 获取最大大小- Returns:
- max size | 最大大小
-