store_base
This module defines the abstract base class for all data store implementations in Merlin.
This module provides the StoreBase class, which outlines the required interface for saving,
retrieving, listing, and deleting entities from a backing data store. All concrete store classes
(e.g., Redis-based stores) must inherit from this class and implement its abstract methods.
StoreBase
Bases: ABC, Generic[T]
Base class for all stores supported in Merlin.
This class defines the methods that are needed for each store in Merlin.
Methods:
| Name | Description |
|---|---|
save |
Save or update an object in the database. |
retrieve |
Retrieve an entity from the database by ID. |
retrieve_all |
Query the database for all entities of this type. |
delete |
Delete an entity from the database by ID. |
Source code in merlin/backends/store_base.py
delete(identifier)
abstractmethod
Delete an entity from the database by an identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
The identifier (typically ID or name) of the entity to delete. |
required |
Source code in merlin/backends/store_base.py
retrieve(identifier)
abstractmethod
Retrieve an entity from the database by an identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
The identifier (typically ID or name) of the entity to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
BaseDataModel
|
The entity if found, None otherwise. |
Source code in merlin/backends/store_base.py
retrieve_all()
abstractmethod
Query the database for all entities of this type.
Returns:
| Type | Description |
|---|---|
List[BaseDataModel]
|
A list of entities. |
Source code in merlin/backends/store_base.py
save(entity)
abstractmethod
Save or update an object in the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity
|
BaseDataModel
|
The object to save. |
required |