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. |
| 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 | 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__ |
Undocumented |
| Instance Variable | _backend |
Undocumented |
| Instance Variable | _prefix |
Undocumented |
Return the cached value for key, or None when absent.
| Parameters | |
key:str | Cache key. |
| Returns | |
Any | Cached value, or None when the key does not exist. |
Return the cached value for key and immediately remove it.
| Parameters | |
key:str | Cache key. |
| Returns | |
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.
| Parameters | |
key:str | Cache key. |
ttl:float | None | TTL applied when storing the resolved value. None means no expiry. |
resolver:Callable | Zero-argument callable that produces the value. May be async. |
| Returns | |
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:Callable | Zero-argument callable that produces the value. May be async. |
| Returns | |
Any | Cached value, or the freshly computed value on a miss. |
Replace a live entry without resurrecting a deleted key.
| Parameters | |
key:str | Existing cache key. |
value: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 | |
CacheStoreException | If the backend has no atomic replacement primitive. |