fleche.storage.memory

Classes

MemoryBackend

A concrete implementation of Storage that stores values in an in-memory dictionary.

ValueMemory

Mixin that locks per-key so concurrent ops on different keys proceed in parallel.

CallMemory

Mixin that locks per-key so concurrent ops on different keys proceed in parallel.

Module Contents

class fleche.storage.memory.MemoryBackend[source]

Bases: fleche.storage.base.StorageBackend

A concrete implementation of Storage that stores values in an in-memory dictionary.

storage: dict[fleche.digest.Digest, Any][source]
__hash__[source]
list() Iterable[fleche.digest.Digest][source]
put(value: Any, key: fleche.digest.Digest) fleche.digest.Digest[source]
get(key: fleche.digest.Digest) Any[source]
_contains(key: fleche.digest.Digest) bool[source]
_evict(key: fleche.digest.Digest) None[source]
class fleche.storage.memory.ValueMemory[source]

Bases: fleche.storage.thread_safe.PerKeyLockMixin, fleche.storage.destructuring.DestructuringMixin, fleche.storage.base.ValueMixin, 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): ...
__hash__[source]
class fleche.storage.memory.CallMemory[source]

Bases: fleche.storage.thread_safe.PerKeyLockMixin, fleche.storage.base.CallMixin, 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): ...
__hash__[source]