hyperion.ports.cache¶
hyperion.ports.cache
¶
Port: a serverless cache for our shenanigans.
Abstract :class:Cache base plus its contract types (:class:CacheStats,
:class:CachingError). Concrete adapters (InMemoryCache, LocalFileCache,
DynamoDBCache) live in hyperion.adapters.cache.*; Cache.from_config
delegates backend selection to :mod:hyperion.composition (the single
composition root). The deprecated PersistentCache (the Catalog knot,
S7) moved to :mod:hyperion.application.persistent_cache.
Cache
¶
Bases: ABC
A serverless cache for our shenanigans.
Initializes the cache with the given prefix and default TTL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prefix
|
str
|
The prefix for the cache keys. |
required |
hash_keys
|
bool
|
Whether to hash the keys. |
True
|
default_ttl
|
int
|
The default TTL for the cache. |
DEFAULT_TTL_SECONDS
|
Source code in hyperion/ports/cache.py
from_config
classmethod
¶
Creates a cache from the configuration.
This function emulates a singleton pattern, so it will return the same instance for the same configuration.
Returns:
| Name | Type | Description |
|---|---|---|
Cache |
Cache
|
A cache instance. |
Source code in hyperion/ports/cache.py
get
¶
Gets a value from the cache.
set
¶
get_bytes
¶
Gets a bytes value from the cache.