graph.data package
Submodules
graph.data.key_value_store module
- class graph.data.key_value_store.KeyValueStore[source]
Bases:
object
In-memory key-value store that saves, retrieves, and merges values by type or custom key.
- storage
Underlying dictionary holding stored values.
- Type:
dict[str, object]
- save(value: object) None [source]
Store a value under its class name.
- Parameters:
value (object) – The object to store.
- Raises:
ValueError – If a value of the same type is already stored.
- get(value_type: type) object [source]
Retrieve a stored value by its class type.
- Parameters:
value_type (type) – The class/type of the value to retrieve.
- Returns:
The stored object.
- Return type:
object
- Raises:
KeyError – If no value of this type is found.
- save_by_key(key: str, value: object) None [source]
Store a value under a custom string key.
- Parameters:
key (str) – The string key to use in storage.
value (object) – The object to store.
- get_by_key(key: str) object [source]
Retrieve a value by a custom string key.
- Parameters:
key (str) – The key to look up.
- Returns:
The stored object.
- Return type:
object
- Raises:
KeyError – If the key is not found.
- save_tickets(tickets: list[object]) None [source]
Store a list of tickets under the ‘tickets’ key.
- Parameters:
tickets (list[object]) – List of ticket objects to store.
- get_tickets() list[object] [source]
Retrieve the list of tickets.
- Returns:
The stored tickets list.
- Return type:
list[object]
- Raises:
KeyError – If no ‘tickets’ entry is found.
- merge(storages: list[Self]) None [source]
Merge multiple KeyValueStore instances into this one.
Combines lists for duplicate keys, overrides otherwise.
- Parameters:
storages (list[KeyValueStore]) – Other store instances to merge.