Skip to content

hyperion.adapters.cache.memory

hyperion.adapters.cache.memory

In-memory :class:Cache adapter (lite -- cachetools-backed).

InMemoryCache

InMemoryCache(prefix, hash_keys=True, default_ttl=DEFAULT_TTL_SECONDS, max_size=MAX_KEYS)

Bases: Cache

An in-memory cache for our shenanigans.

Source code in hyperion/adapters/cache/memory.py
def __init__(
    self, prefix: str, hash_keys: bool = True, default_ttl: int = DEFAULT_TTL_SECONDS, max_size: int = MAX_KEYS
):
    super().__init__(prefix, hash_keys, default_ttl)
    self.max_size = max_size
    self.cache = cachetools.TTLCache[str, str](maxsize=self.max_size, ttl=self.default_ttl)