Interface FeatureStore

All Known Implementing Classes:
CachedFeatureStore, FileFeatureStore, InMemoryFeatureStore, LruFeatureStore, RedisFeatureStore

public interface FeatureStore
Feature Store Interface 功能存储接口

Interface for storing and retrieving feature definitions.

用于存储和检索功能定义的接口。

Implementations | 实现:

Usage Examples | 使用示例:

FeatureStore store = new InMemoryFeatureStore();
store.save(Feature.builder("feature-1").alwaysOn().build());

Optional<Feature> feature = store.find("feature-1");
List<Feature> all = store.findAll();

Features | 主要功能:

  • CRUD operations for feature flag persistence - 功能标志持久化的CRUD操作
  • Listener support for change notification - 变更通知的监听器支持

Security | 安全性:

  • Thread-safe: Implementation-dependent - 线程安全: 取决于实现
  • Null-safe: No - 空值安全: 否
Since:
JDK 25, opencode-base-feature V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear all features 清除所有功能
    default int
    Get the count of features 获取功能数量
    boolean
    Delete a feature 删除功能
    default boolean
    Check if a feature exists 检查功能是否存在
    find(String key)
    Find a feature by key 根据键查找功能
    Find all features 查找所有功能
    void
    save(Feature feature)
    Save a feature 保存功能
  • Method Details

    • save

      void save(Feature feature)
      Save a feature 保存功能
      Parameters:
      feature - the feature to save | 要保存的功能
    • find

      Optional<Feature> find(String key)
      Find a feature by key 根据键查找功能
      Parameters:
      key - the feature key | 功能键
      Returns:
      optional containing feature if found | 如果找到则包含功能的Optional
    • findAll

      List<Feature> findAll()
      Find all features 查找所有功能
      Returns:
      list of all features | 所有功能的列表
    • delete

      boolean delete(String key)
      Delete a feature 删除功能
      Parameters:
      key - the feature key | 功能键
      Returns:
      true if deleted | 如果删除成功返回true
    • exists

      default boolean exists(String key)
      Check if a feature exists 检查功能是否存在
      Parameters:
      key - the feature key | 功能键
      Returns:
      true if exists | 如果存在返回true
    • count

      default int count()
      Get the count of features 获取功能数量
      Returns:
      feature count | 功能数量
    • clear

      void clear()
      Clear all features 清除所有功能