betty.store module¶
The key-value store API.
- class betty.store.Store¶
-
A key-value store.
To test your own subclasses, use
betty.test_utils.store.StoreTestBase.This is thread-safe, which means you can safely use this between different threads.
- abstractmethod async get(key: str, /) StoreItem[ItemValueT] | None¶
Get the item with the given key.
- abstractmethod getset(key: str, /) AbstractAsyncContextManager[StoreItemValueSetter[ItemValueT] | StoreItem[ItemValueT]]¶
Get the item with the given key, or provide a setter to add it within the same atomic operation.
- abstractmethod hasset(key: str, /) AbstractAsyncContextManager[StoreItemValueSetter[ItemValueT] | None]¶
Check if an item with the given key exists, and if not, provide a setter to add or update it within the same atomic operation.
- class betty.store.StoreItem¶
-
A store item.
- abstractmethod async value() ItemValueT¶
Get this item’s value.