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

class FileCacheBackend: (source)

Constructor: FileCacheBackend(path)

View In Hierarchy

Undocumented

Static Method __readEntryUnlocked Read a cache entry while its file lock is held.
Static Method __tempPath Return a unique staging path for file.
Method __createSync Write entry to file only when the file does not exist yet.
Method __file Return the filesystem path for key.
Method __incrementSync Update a counter while holding its file lock.
Method __init__ Initialize the backend and create the cache directory if needed.
Method __lock Select the stable cross-process lock stripe for a cache file.
Method __readSync Read and decode a cache file synchronously.
Method __replaceIfPresent Replace a live entry while holding its cross-process lock.
Method __replaceSync Publish tmp as file, retrying a transient sharing violation.
Method __unlinkSync Remove file, ignoring missing-file errors.
Method __writeEntryUnlocked Publish a cache entry while its file lock is held.
Method __writeSync Atomically write entry to file via tmp-then-rename.
Async Method add Store value under key only if the key does not already exist.
Async Method clear Remove all cache entries from the store directory.
Async Method delete Remove key from the store.
Async Method exists Return True if key exists and has not expired.
Async Method get Return the cached value for key, or default when absent/expired.
Async Method increment Increment the integer stored at key by delta.
Async Method multiGet Return a list of values for keys in the same order.
Async Method multiSet Store multiple key/value pairs with an optional TTL.
Async Method replace Replace an existing live key without recreating a deleted entry.
Async Method set Store value under key with an optional TTL in seconds.
Class Variable __slots__ Undocumented
Instance Variable _counter_lock Undocumented
Instance Variable _locks Undocumented
Instance Variable _path Undocumented
Instance Variable _rename_lock Undocumented
Property lockNamespace Return the canonical directory used to identify cache locks.
def __readEntryUnlocked(file: Path) -> dict | None: (source)

Read a cache entry while its file lock is held.

Parameters
file:PathPath to the cache entry.
Returns
dict | NoneLive decoded entry, or None when missing, expired, or invalid.
def __tempPath(file: Path) -> Path: (source)

Return a unique staging path for file.

Parameters
file:PathTarget cache file.
Returns
PathSibling path ending in .tmp that no concurrent writer of the same key can collide with.
def __createSync(self, file: Path, entry: dict) -> bool: (source)

Write entry to file only when the file does not exist yet.

Parameters
file:PathTarget cache file.
entry:dictSerializable cache entry.
Returns
boolTrue when the file was created by this call, False when another writer got there first.
def __file(self, key: str) -> Path: (source)

Return the filesystem path for key.

Parameters
key:strCache key.
Returns
PathPath to the corresponding .json file.
def __incrementSync(self, file: Path, delta: int) -> int: (source)

Update a counter while holding its file lock.

Parameters
file:PathCounter file to update.
delta:intAmount to add to the current value.
Returns
intUpdated counter value.
def __init__(self, path: Path): (source)

Initialize the backend and create the cache directory if needed.

Parameters
path:PathDirectory where cache files will be stored.
Returns
NoneComplete the documented operation without returning a value.
def __lock(self, file: Path) -> BaseFileLock: (source)

Select the stable cross-process lock stripe for a cache file.

Parameters
file:PathCache file protected by the lock.
Returns
BaseFileLockPlatform lock shared by writes, replacement and deletion.
def __readSync(self, file: Path) -> dict | None: (source)

Read and decode a cache file synchronously.

Parameters
file:PathPath to the cache file.
Returns
dict | NoneDecoded entry, or None on any error.
def __replaceIfPresent(self, file: Path, entry: dict) -> bool: (source)

Replace a live entry while holding its cross-process lock.

Parameters
file:PathTarget cache file.
entry:dictEncoded replacement entry.
Returns
boolFalse when the previous entry has disappeared or expired.
def __replaceSync(self, tmp: Path, file: Path): (source)

Publish tmp as file, retrying a transient sharing violation.

Parameters
tmp:PathStaging file holding the encoded entry.
file:PathDestination cache file.
Returns
NoneComplete the documented operation without returning a value.
Raises
OSErrorIf the rename keeps failing after the last attempt.
def __unlinkSync(self, file: Path) -> int: (source)

Remove file, ignoring missing-file errors.

Parameters
file:PathFile to remove.
Returns
intOne when a file was removed, otherwise zero.
def __writeEntryUnlocked(self, file: Path, entry: dict): (source)

Publish a cache entry while its file lock is held.

Parameters
file:PathDestination cache file.
entry:dictEncodable cache entry.
Returns
NoneComplete the documented operation without returning a value.
Raises
OSErrorIf staging or publishing the entry fails.
def __writeSync(self, file: Path, entry: dict): (source)

Atomically write entry to file via tmp-then-rename.

Parameters
file:PathTarget cache file.
entry:dictSerializable cache entry.
Returns
NoneComplete the documented operation without returning a value.
Raises
OSErrorIf the entry cannot be staged or renamed into place.
async def add(self, key: str, value: Any, ttl: float | None = None) -> bool: (source)

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

The entry is created with an exclusive open, so concurrent callers never both succeed and the operation is safe as a mutual-exclusion primitive.

Parameters
key:strCache key.
value:AnyValue to store.
ttl:float | NoneOptional TTL in seconds.
Returns
boolTrue on success.
Raises
ValueErrorIf the key already exists and has not expired.
async def clear(self) -> bool: (source)

Remove all cache entries from the store directory.

Returns
boolAlways True.
async def delete(self, key: str) -> int: (source)

Remove key from the store.

Parameters
key:strCache key.
Returns
int1 if the key existed, 0 otherwise.
async def exists(self, key: str) -> bool: (source)

Return True if key exists and has not expired.

Parameters
key:strCache key.
Returns
boolUndocumented
async def get(self, key: str, default: Any = None) -> Any: (source)

Return the cached value for key, or default when absent/expired.

Expired entries are deleted on first read (lazy eviction).

Parameters
key:strCache key.
default:AnyValue returned when the key is not found or has expired.
Returns
AnyStored value or default.
async def increment(self, key: str, delta: int = 1) -> int: (source)

Increment the integer stored at key by delta.

Creates the key with value delta if it does not exist, and keeps the expiry of an existing entry untouched.

Parameters
key:strCache key.
delta:intAmount to add (use negative values to decrement).
Returns
intNew value after increment.
async def multiGet(self, keys: list[str], default: Any = None) -> list[Any]: (source)

Return a list of values for keys in the same order.

Parameters
keys:list[str]Cache keys.
default:AnyReturned for each missing/expired key.
Returns
list[Any]Undocumented
async def multiSet(self, pairs: list[tuple[str, Any]], ttl: float | None = None) -> bool: (source)

Store multiple key/value pairs with an optional TTL.

Parameters
pairs:list[tuple[str, Any]]Sequence of (key, value) pairs.
ttl:float | NoneShared TTL applied to every pair.
Returns
boolAlways True.
async def replace(self, key: str, value: Any, ttl: float | None = None) -> bool: (source)

Replace an existing live key without recreating a deleted entry.

Parameters
key:strExisting cache key.
value:AnyReplacement value.
ttl:float | NoneReplacement lifetime in seconds.
Returns
boolWhether the entry was replaced atomically.
async def set(self, key: str, value: Any, ttl: float | None = None) -> bool: (source)

Store value under key with an optional TTL in seconds.

Parameters
key:strCache key.
value:AnyJSON-serializable value to cache.
ttl:float | NoneTime-to-live in seconds. None means no expiry.
Returns
boolAlways True.
__slots__: tuple[str, ...] = (source)

Undocumented

_counter_lock = (source)

Undocumented

Undocumented

Undocumented

_rename_lock = (source)

Undocumented

lockNamespace: Path = (source)

Return the canonical directory used to identify cache locks.

Returns
PathAbsolute directory shared by backends storing the same files.