THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
class CacheRepository(ICacheRepository): (source)
Constructor: CacheRepository(backend, prefix)
Async cache repository backed by a configurable storage backend.
Wraps a low-level backend with optional key-prefix support and exposes a higher-level API (get, set, remember, lock, …).
| Method | __init__ |
Initialise the repository with a backend and an optional key prefix. |
| Async Method | _get |
Read a value without confusing serialized null with a missing key. |
| Method | _k |
Return the prefixed form of key. |
| Async Method | add |
Store value under key only when the key does not already exist. |
| Async Method | clear |
Remove all entries from the cache store. |
| Async Method | decrement |
Decrement the integer stored at key by amount. |
| Async Method | delete |
Remove key from the cache store. |
| Async Method | get |
Return the cached value for key, or None when absent. |
| Async Method | get |
Return a mapping of key → value for all requested keys. |
| Async Method | has |
Return True if key exists and has not expired. |
| Async Method | increment |
Increment the integer stored at key by amount. |
| Method | lock |
Return an async context manager that acquires a distributed lock. |
| Async Method | pull |
Return the cached value for key and immediately remove it. |
| Async Method | remember |
Return the cached value for key, computing it on a cache miss. |
| Async Method | remember |
Cache the value for key indefinitely, resolving on a miss. |
| Async Method | remember |
Coalesce concurrent misses without changing remember semantics. |
| Async Method | replace |
Replace a live entry without resurrecting a deleted key. |
| Async Method | set |
Store value under key with an optional time-to-live. |
| Async Method | set |
Store multiple key/value pairs with an optional shared TTL. |
| Class Variable | __slots__ |
Declare the instance attribute slots reserved by this class. |
| Instance Variable | _backend |
Storage backend implementing the low-level cache protocol. |
| Instance Variable | _prefix |
String prepended to every key, separated by :. |
Initialise the repository with a backend and an optional key prefix.
| Parameters | |
backend:typing.Any | Storage backend implementing the low-level cache protocol. |
prefix:str, optional | String prepended to every key, separated by :. |
| Returns | |
None | No return value. |
Store value under key only when the key does not already exist.
| Parameters | |
key:str | Cache key. |
value:typing.Any | Value to store. |
ttl:float | None, optional | Optional time-to-live in seconds. |
| Returns | |
bool | True on success, False when the key already exists. |
Return the cached value for key, or None when absent.
| Parameters | |
key:str | Cache key. |
| Returns | |
typing.Any | Cached value, or None when the key does not exist. |
Return a mapping of key → value for all requested keys.
| Parameters | |
keys:list[str] | Cache keys to fetch. |
| Returns | |
dict[str, typing.Any] | Mapping that preserves the original (un-prefixed) key names. |
Return an async context manager that acquires a distributed lock.
| Parameters | |
key:str | Resource key to lock. |
timeout:float | None, optional | Store-specific acquisition deadline or lease duration in seconds. None leaves file/database acquisition unbounded and uses the default lease for database and aiocache backends. |
| Returns | |
orionis.cache.locks.lock.CacheLock | Async context manager for the requested lock. |
Return the cached value for key and immediately remove it.
| Parameters | |
key:str | Cache key. |
| Returns | |
typing.Any | Cached value, or None when the key is absent. |
Return the cached value for key, computing it on a cache miss.
If the key is absent, call resolver (sync or async), persist the result for ttl seconds, and return it. Configured Orionis JSON stores distinguish cached None from missing data; custom stores must preserve that distinction in their serialized representation or read operation.
| Parameters | |
key:str | Cache key. |
ttl:float | None | TTL applied when storing the resolved value. None means no expiry. |
resolver:collections.abc.Callable | Zero-argument callable that produces the value. May be async. |
| Returns | |
typing.Any | Cached value, or the freshly computed value on a miss. |
Cache the value for key indefinitely, resolving on a miss.
| Parameters | |
key:str | Cache key. |
resolver:collections.abc.Callable | Zero-argument callable that produces the value. May be async. |
| Returns | |
typing.Any | Cached value, or the freshly computed value on a miss. |
Self, key: str, ttl: float | None, resolver: Callable, *, wait_timeout: float = 10, lease: float | None = None) -> Any:
(source)
¶
Coalesce concurrent misses without changing remember semantics.
| Parameters | |
key:str | Cache key within this repository's prefix. |
ttl:float | None | Lifetime of the computed value, including a stored None. |
resolver:collections.abc.Callable | Synchronous or asynchronous value producer. |
waitfloat | Maximum local or Redis admission wait in seconds, per phase. |
lease:float | None | Optional backend lock lease for cross-process coalescing. Backend lock guarantees apply; a resolver must finish within the lease. |
| Returns | |
typing.Any | Cached or freshly resolved value. Failed or cancelled owners do not retain local locks; a later caller can retry. |
Replace a live entry without resurrecting a deleted key.
| Parameters | |
key:str | Existing cache key. |
value:typing.Any | Replacement value. |
ttl:float | None | New lifetime in seconds, or None for no expiry. |
| Returns | |
bool | True when the backend atomically accepted the replacement. |
| Raises | |
orionis.cache.exceptions.CacheStoreException | If the backend has no atomic replacement primitive. |
Store value under key with an optional time-to-live.
| Parameters | |
key:str | Cache key. |
value:typing.Any | Value to store. |
ttl:float | None, optional | Time-to-live in seconds. None means no expiry. |
| Returns | |
bool | True on success. |
Store multiple key/value pairs with an optional shared TTL.
| Parameters | |
values:dict[str, typing.Any] | Mapping of key → value to store. |
ttl:float | None, optional | Shared time-to-live in seconds. None means no expiry. |
| Returns | |
bool | True on success. |