fleche.storage.memory ===================== .. py:module:: fleche.storage.memory Classes ------- .. autoapisummary:: fleche.storage.memory.MemoryBackend fleche.storage.memory.ValueMemory fleche.storage.memory.CallMemory Module Contents --------------- .. py:class:: MemoryBackend Bases: :py:obj:`fleche.storage.base.StorageBackend` A concrete implementation of Storage that stores values in an in-memory dictionary. .. py:attribute:: storage :type: dict[fleche.digest.Digest, Any] .. py:method:: list() -> Iterable[fleche.digest.Digest] .. py:method:: put(value: Any, key: fleche.digest.Digest) -> fleche.digest.Digest .. py:method:: get(key: fleche.digest.Digest) -> Any .. py:method:: _contains(key: fleche.digest.Digest) -> bool .. py:method:: _evict(key: fleche.digest.Digest) -> None .. py:class:: ValueMemory Bases: :py:obj:`fleche.storage.destructuring.DestructuringMixin`, :py:obj:`fleche.storage.base.ValueMixin`, :py:obj:`MemoryBackend` Mixin that recursively destructures collections on save/load. Place before a :class:`ValueMixin` in the MRO to add destructuring behavior. Lists, tuples, and dicts are broken apart so each element is stored independently; on load the original structure is reassembled. .. rubric:: Example >>> from fleche.storage.base import ValueMixin >>> from fleche.storage.memory import MemoryBackend >>> @dataclass(frozen=True) ... class MyValueStorage(DestructuringMixin, ValueMixin, MemoryBackend): ... >>> vm = MyValueStorage(storage={}) >>> key = vm.save([1, [2, 3]]) >>> vm.load(key) == [1, [2, 3]] True .. py:class:: CallMemory Bases: :py:obj:`fleche.storage.base.CallMixin`, :py:obj:`MemoryBackend` Bridges :class:`CallStorage` with :class:`StorageBackend` primitives. Implements ``save``, ``load``, and ``query`` using ``put`` and ``get``, deriving the storage key from the call's lookup key. ``transform`` is inherited from :class:`CallStorage`. Concrete classes inherit from this and a :class:`StorageBackend` implementation to get a fully functional call storage.