julee.repositories.memory.base ============================== .. py:module:: julee.repositories.memory.base .. autoapi-nested-parse:: Memory repository base classes and mixins. This module provides common functionality for in-memory repository implementations, reducing code duplication and ensuring consistent patterns across all memory-based repositories in the julee domain. The MemoryRepositoryMixin encapsulates common patterns like: - Dictionary-based storage management - Standardized logging patterns - ID generation with consistent prefixes - Timestamp management (created_at, updated_at) - Generic CRUD operations with proper error handling Classes using this mixin must provide: - self.storage_dict: Dict[str, T] for entity storage - self.entity_name: str for logging and ID generation - self.logger: logging.Logger instance Attributes ---------- .. autoapisummary:: julee.repositories.memory.base.T Classes ------- .. autoapisummary:: julee.repositories.memory.base.MemoryRepositoryMixin Module Contents --------------- .. py:class:: MemoryRepositoryMixin Bases: :py:obj:`Generic`\ [\ :py:obj:`T`\ ] Mixin that provides common repository patterns for memory implementations. This mixin encapsulates common functionality used across all memory repository implementations, including: - Dictionary-based entity storage and retrieval - Standardized logging patterns with consistent messaging - ID generation with configurable prefixes - Timestamp management (created_at if None, always updated_at) - Generic error handling patterns Classes using this mixin must provide: - self.storage_dict: Dict[str, T] instance for entity storage - self.entity_name: str for logging and ID generation prefixes - self.logger: logging.Logger instance (typically set in __init__) .. py:method:: generate_entity_id(prefix = None) Generate a unique entity ID with consistent format. :param prefix: Optional prefix for the ID. If None, uses entity_name :returns: Unique entity ID string in format "{prefix}-{uuid}" .. py:method:: get_entity(entity_id) Get an entity from memory storage with standardized logging. :param entity_id: Unique entity identifier :returns: Entity if found, None otherwise .. py:method:: get_many_entities(entity_ids) Get multiple entities from memory storage with standardized logging. :param entity_ids: List of unique entity identifiers :returns: Dict mapping entity_id to entity (or None if not found) .. py:method:: save_entity(entity, entity_id_field) Save an entity to memory storage with timestamp management. :param entity: Entity to save :param entity_id_field: Name of the ID field on the entity .. py:method:: update_timestamps(entity) Update timestamps on an entity (created_at if None, always updated_at). :param entity: Pydantic model with created_at and updated_at fields .. py:attribute:: entity_name :type: str .. py:attribute:: logger :type: Any .. py:attribute:: storage_dict :type: dict[str, T] .. py:data:: T