Class InMemoryFeatureStore
java.lang.Object
cloud.opencode.base.feature.store.InMemoryFeatureStore
- All Implemented Interfaces:
FeatureStore
In-Memory Feature Store
内存功能存储
Thread-safe in-memory implementation of FeatureStore.
FeatureStore的线程安全内存实现。
Features | 主要功能:
- Thread-safe operations - 线程安全操作
- Fast lookups - 快速查找
- No persistence - 无持久化
Usage Examples | 使用示例:
FeatureStore store = new InMemoryFeatureStore();
store.save(Feature.builder("feature-1").alwaysOn().build());
store.save(Feature.builder("feature-2").percentage(50).build());
boolean exists = store.exists("feature-1"); // true
int count = store.count(); // 2
- Since:
- JDK 25, opencode-base-feature V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
InMemoryFeatureStore
public InMemoryFeatureStore()Create in-memory store 创建内存存储
-
-
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
-