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.

@override

void configure(ConfigParams config)

  • config: ConfigParams - configuration parameters to be set.

delete

Deletes a state from the store by its key.

Future<T?> delete<T>(IContext? context, String key)

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

load

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

Future<T?> load<T>(IContext? context, String key)

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

loadBulk

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

Future<List<StateValue<T>>> loadBulk<T>(IContext? context, List<String> keys)

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

save

Saves state into the store.

Future<T> save<T>(IContext? context, String key, value)

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

Examples

var store = MemoryStateStore();

var value = await store.load("123", "key1");
...
await store.save("123", "key1", "ABC");

See also