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:attribute:: __hash__ .. 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.thread_safe.PerKeyLockMixin`, :py:obj:`fleche.storage.destructuring.DestructuringMixin`, :py:obj:`fleche.storage.base.ValueMixin`, :py:obj:`MemoryBackend` Mixin that locks per-key so concurrent ops on different keys proceed in parallel. A lightweight ``threading.Lock`` guards the lock-table itself; once the per-key ``RLock`` is obtained the table lock is released, so two threads operating on *different* keys never block each other. Operations on the *same* key are serialized by the per-key lock, which is reentrant to allow nested calls (e.g. ``expand`` inside ``load``). Instances must be hashable. Place before the concrete storage class in the MRO:: @dataclass(frozen=True) class PerKeyValuePickle(PerKeyLockMixin, ValuePickleFile): ... .. py:attribute:: __hash__ .. py:class:: CallMemory Bases: :py:obj:`fleche.storage.thread_safe.PerKeyLockMixin`, :py:obj:`fleche.storage.base.CallMixin`, :py:obj:`MemoryBackend` Mixin that locks per-key so concurrent ops on different keys proceed in parallel. A lightweight ``threading.Lock`` guards the lock-table itself; once the per-key ``RLock`` is obtained the table lock is released, so two threads operating on *different* keys never block each other. Operations on the *same* key are serialized by the per-key lock, which is reentrant to allow nested calls (e.g. ``expand`` inside ``load``). Instances must be hashable. Place before the concrete storage class in the MRO:: @dataclass(frozen=True) class PerKeyValuePickle(PerKeyLockMixin, ValuePickleFile): ... .. py:attribute:: __hash__