ORIONIS API REFERENCE

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 documentation

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 getMany 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 rememberForever 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 setMany Store multiple key/value pairs with an optional shared TTL.
Class Variable __slots__ Undocumented
Instance Variable _backend Undocumented
Instance Variable _prefix Undocumented
def __init__(self, backend: Any, prefix: str = ''): (source)

Initialise the repository with a backend and an optional key prefix.

Parameters
backend:AnyStorage backend implementing the low-level cache protocol.
prefix:str, optionalString prepended to every key, separated by :.
Returns
NoneComplete the documented operation without returning a value.
def _k(self, key: str) -> str: (source)

Return the prefixed form of key.

Parameters
key:strRaw cache key.
Returns
strPrefixed key, or the original key when no prefix is configured.
async def add(self, key: str, value: Any, ttl: float | None = None) -> bool: (source)

Store value under key only when the key does not already exist.

Parameters
key:strCache key.
value:AnyValue to store.
ttl:float | None, optionalOptional time-to-live in seconds.
Returns
boolTrue on success, False when the key already exists.
async def clear(self) -> bool: (source)

Remove all entries from the cache store.

Returns
boolTrue on success.
async def decrement(self, key: str, amount: int = 1) -> int: (source)

Decrement the integer stored at key by amount.

Parameters
key:strCache key.
amount:int, optionalPositive integer to subtract. Defaults to 1.
Returns
intNew value after the decrement.
async def delete(self, key: str) -> bool: (source)

Remove key from the cache store.

Parameters
key:strCache key.
Returns
boolTrue if the key existed and was removed, False otherwise.
async def get(self, key: str) -> Any: (source)

Return the cached value for key, or None when absent.

Parameters
key:strCache key.
Returns
AnyCached value, or None when the key does not exist.
async def getMany(self, keys: list[str]) -> dict[str, Any]: (source)

Return a mapping of key → value for all requested keys.

Parameters
keys:list[str]Cache keys to fetch.
Returns
dict[str, Any]Mapping that preserves the original (un-prefixed) key names.
async def has(self, key: str) -> bool: (source)

Return True if key exists and has not expired.

Parameters
key:strCache key.
Returns
boolTrue when the key is present and still valid.
async def increment(self, key: str, amount: int = 1) -> int: (source)

Increment the integer stored at key by amount.

Parameters
key:strCache key.
amount:int, optionalPositive integer to add. Defaults to 1.
Returns
intNew value after the increment.
def lock(self, key: str, timeout: float | None = None) -> CacheLock: (source)

Return an async context manager that acquires a distributed lock.

Parameters
key:strResource key to lock.
timeout:float | None, optionalMaximum lock duration in seconds. None means no timeout.
Returns
CacheLockAsync context manager for the requested lock.
async def pull(self, key: str) -> Any: (source)

Return the cached value for key and immediately remove it.

Parameters
key:strCache key.
Returns
AnyCached value, or None when the key is absent.
async def remember(self, key: str, ttl: float | None, resolver: Callable) -> Any: (source)

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:strCache key.
ttl:float | NoneTTL applied when storing the resolved value. None means no expiry.
resolver:CallableZero-argument callable that produces the value. May be async.
Returns
AnyCached value, or the freshly computed value on a miss.
async def rememberForever(self, key: str, resolver: Callable) -> Any: (source)

Cache the value for key indefinitely, resolving on a miss.

Parameters
key:strCache key.
resolver:CallableZero-argument callable that produces the value. May be async.
Returns
AnyCached value, or the freshly computed value on a miss.
async def replace(self, key: str, value: Any, ttl: float | None = None) -> bool: (source)

Replace a live entry without resurrecting a deleted key.

Parameters
key:strExisting cache key.
value:AnyReplacement value.
ttl:float | NoneNew lifetime in seconds, or None for no expiry.
Returns
boolTrue when the backend atomically accepted the replacement.
Raises
CacheStoreExceptionIf the backend has no atomic replacement primitive.
async def set(self, key: str, value: Any, ttl: float | None = None) -> bool: (source)

Store value under key with an optional time-to-live.

Parameters
key:strCache key.
value:AnyValue to store.
ttl:float | None, optionalTime-to-live in seconds. None means no expiry.
Returns
boolTrue on success.
async def setMany(self, values: dict[str, Any], ttl: float | None = None) -> bool: (source)

Store multiple key/value pairs with an optional shared TTL.

Parameters
values:dict[str, Any]Mapping of key → value to store.
ttl:float | None, optionalShared time-to-live in seconds. None means no expiry.
Returns
boolTrue on success.
_backend = (source)

Undocumented

Undocumented