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

In-memory cache of translation maps keyed by locale.

Recently used locales are retained within a configurable capacity. Missing locales expire so newly created translation files can be found.

Notes

A reentrant lock protects cache and loader access across threads. orionis.localization.TranslationRepository.get returns the cached mapping itself, not a copy.

Method __init__ Initialize the repository with its translation loader.
Method flush Discard every cached translation map.
Method forget Discard the cached translations for locale.
Method get Return the translation map for locale, loading it on demand.
Method has Determine whether locale is already cached in memory.
Method loadedLocales Return the locales currently held in the cache.
Class Variable __slots__ Declare the instance attribute slots reserved by this class.
Instance Variable _cache Cache policy or cached state used by this component.
Instance Variable _expires Expiration deadline for the cached or protected value.
Instance Variable _limit Maximum retained locales, including empty results.
Instance Variable _loader Loader used to read translation sources on cache misses.
Instance Variable _lock Lock protecting concurrent access to shared state.
Instance Variable _negative_ttl Seconds to retain an empty result before retrying the loader.
def __init__(self: Self, loader: ITranslationLoader, *, max_locales: int = 256, negative_ttl: float = 30): (source)

Initialize the repository with its translation loader.

Parameters
loader:orionis.localization.contracts.ITranslationLoaderLoader used to read translation sources on cache misses.
max_locales:intMaximum retained locales, including empty results.
negative_ttl:floatSeconds to retain an empty result before retrying the loader.
Returns
NoneNo return value.
Raises
ValueErrorIf the capacity is not a positive integer or the negative-cache lifetime is nonfinite or negative.
TypeErrorIf the negative-cache lifetime is not numeric.
def flush(self: Self): (source)

Discard every cached translation map.

Returns
NoneNo return value.
def forget(self: Self, locale: str) -> bool: (source)

Discard the cached translations for locale.

Parameters
locale:strLocale code whose cache entry must be removed.
Returns
boolTrue when an entry was removed, False otherwise.
def get(self: Self, locale: str) -> TranslationMap: (source)

Return the translation map for locale, loading it on demand.

Parameters
locale:strLocale code whose translations are requested.
Returns
orionis.localization.types.TranslationMapCached translation map for the locale. The mapping is the cached instance, not a copy.
Raises
orionis.localization.TranslationSyntaxExceptionIf a translation file contains invalid JSON.
def has(self: Self, locale: str) -> bool: (source)

Determine whether locale is already cached in memory.

Parameters
locale:strLocale code to check.
Returns
boolTrue when the locale is present in the cache.
def loadedLocales(self: Self) -> tuple[str, ...]: (source)

Return the locales currently held in the cache.

Returns
tuple[str, ...]Unexpired locale codes, ordered from least to most recently used.
__slots__: tuple[str, ...] = (source)

Declare the instance attribute slots reserved by this class.

_cache: OrderedDict[str, TranslationMap] = (source)

Cache policy or cached state used by this component.

Expiration deadline for the cached or protected value.

Maximum retained locales, including empty results.

Loader used to read translation sources on cache misses.

Lock protecting concurrent access to shared state.

_negative_ttl = (source)

Seconds to retain an empty result before retrying the loader.