system.stores.VersionedKeyValueStore module

Versioned (copy-on-write) key-value store.

class system.stores.VersionedKeyValueStore.HashableDict[source]

Bases: dict

A hashable dictionary class that can be used as a key in a dictionary. In particular, you can create a set of these dictionaries.

class system.stores.VersionedKeyValueStore.VersionedKeyValueStore(persistence_layer: KeyValueStore = None)[source]

Bases: KeyValueStore[str, object]

A versioned store managing key/value mappings.

class VersionEntry(*, start_validity: int)[source]

Bases: ABC, BaseModel

An abstract class representing a version entry in the store, i.e. an entry of a single object/value plus start_validity information, i.e. when the object was created or updated.

start_validity: int
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class UpdateEntry(*, start_validity: int, value: object)[source]

Bases: VersionEntry

A class representing an update or creation entry in the store, i.e. an entry of a single object/value plus start_validity information, i.e. when the object was updated or created.

value: object
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class DeleteEntry(*, start_validity: int)[source]

Bases: VersionEntry

A class representing a delete version entry in the store, i.e. just the start_validity information, i.e. since when the object is considered deleted.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class KVStoreEntry(committed: list[VersionEntry], wip: VersionEntry | None = None)[source]

Bases: object

A class representing a key value store entry.

committed: list[VersionEntry]
wip: VersionEntry | None = None
size() → int[source]

See Index.size().

put(object_id: str, _object: object) → None | PutInfo[source]

See Index.put().

Non-transactional insert: the object is deep-copied and recorded as a single committed version with start timestamp 0, bypassing the store’s transactional semantics (use TransactionalKeyValueStore for those). Raises if the object_id already exists.

get(object_id: str) → Iterator[object][source]

See PointQueryMixIn.get().

Yields only the value of the most recent committed version; delete markers are not taken into account. Raises if the object_id is not present.

delete(object_id: str, _object: object = None) → None[source]

See Index.delete().

Non-transactional delete: requires _object to be None and appends a delete marker as a committed version with start timestamp 0. Raises if the object_id is not present.

flush(object_id: int | None = None) → None[source]

See Index.flush().

No-op: this store keeps its data in volatile memory only and is not backed by persistent storage.

show() → None[source]

See Index.show().

Pretty-prints the underlying key-value store.