All Known Implementing Classes:
InMemoryStore

public interface BaseStore
Abstract interface for a namespace-based key-value store.

Items are organized by namespaces (hierarchical path-like tuples) and identified by a key within each namespace.

  • Method Details

    • get

      StoreItem get(List<String> namespace, String key)
      Get a single item by namespace and key.
      Parameters:
      namespace - hierarchical namespace path
      key - the item key within the namespace
      Returns:
      the store item, or null if not found
    • put

      void put(List<String> namespace, String key, Map<String,Object> value)
      Store or update an item.
      Parameters:
      namespace - hierarchical namespace path
      key - the item key within the namespace
      value - the data to store
    • putIfVersion

      default boolean putIfVersion(List<String> namespace, String key, Map<String,Object> value, long expectedVersion)
      Conditional update: stores the item only when the current stored version matches expectedVersion.

      This is a compare-and-swap (CAS) operation that prevents lost updates when multiple writers concurrently modify the same key. Callers should:

      1. Read the item with get(java.util.List<java.lang.String>, java.lang.String) and remember StoreItem.version().
      2. Compute the new value locally.
      3. Call putIfVersion passing the remembered version as expectedVersion.
      4. If the call returns false, the item was modified by another writer; retry from step 1.

      A special value of 0 for expectedVersion means "write only if the key does not yet exist" (i.e. create-if-absent).

      The default implementation always returns false so that existing store implementations compile without changes. Backends that support distributed deployments should override this method with a proper server-side atomic check.

      Parameters:
      namespace - hierarchical namespace path
      key - the item key within the namespace
      value - the new data to store
      expectedVersion - the version the caller observed; must match the current stored version
      Returns:
      true if the item was written, false if the version did not match
    • search

      List<StoreItem> search(List<String> namespace, int limit, int offset)
      Search for items within a namespace with pagination.
      Parameters:
      namespace - hierarchical namespace path
      limit - maximum number of items to return
      offset - number of items to skip
      Returns:
      list of matching store items
    • delete

      void delete(List<String> namespace, String key)
      Delete an item by namespace and key.
      Parameters:
      namespace - hierarchical namespace path
      key - the item key to delete