MemoryStateStore

State store that keeps states in the process memory.

Implements: IReconfigurable, IStateStore

Description

Remember: This implementation is not suitable for synchronization of distributed processes.

Configuration parameters

options:

  • timeout: default caching timeout in milliseconds (default: disabled)

Instance methods

configure

Configures component by passing configuration parameters.

public void configure(ConfigParams configParams) throws ConfigException

  • config: ConfigParams - configuration parameters to be set.

delete

Deletes a state from the store by its key.

public T delete(IContext context, String key)

  • context: IContext - (optional) a context to trace execution through call chain.
  • key: String - a unique value key.
  • return: T - removed item

load

Loads state from the store using its key. If value is missing in the store it returns null.

public T load(IContext context, String key)

  • context: IContext - (optional) a context to trace execution through call chain.
  • key: String - a unique state key.
  • return: T - the state value or null if value wasn’t found.

loadBulk

Loads an array of states from the store using their keys.

public List<StateValue> loadBulk(IContext context, List keys)

  • context: IContext - (optional) a context to trace execution through call chain.
  • keys: List - unique state keys.
  • returns: List<StateValue> - an array with state values and their corresponding keys.

save

Saves state into the store.

public T save(IContext context, String key, T value)

  • context: IContext - (optional) a context to trace execution through call chain.
  • key: String - a unique state key.
  • value: T - a state value.
  • returns: T - execution duration in milliseconds.

Examples

{@code
   MemoryStateStore store = new MemoryStateStore();
 
   String value = store.load("123", "key1");
   ...
   store.save("123", "key1", "ABC");
   }

See also