mex.backend.cache package¶
Submodules¶
mex.backend.cache.connector module¶
- class mex.backend.cache.connector.CacheConnector¶
Bases:
BaseConnector
Connector to handle getting and setting cache values.
Depending on whether redis_url is configured, this cache connector will use either a redis server or a local dictionary cache.
- __init__() None ¶
Create a new cache connector instance.
- close() None ¶
Close the connector’s underlying sockets.
- flush() None ¶
Flush the cache (only in debug mode).
- get_value(key: str) dict[str, Any] | None ¶
Return the value for the given key.
- metrics() dict[str, int] ¶
Generate metrics about the underlying cache.
- set_value(key: str, model: BaseModel) None ¶
Return the value for the given key.
- class mex.backend.cache.connector.CacheProto(*args, **kwargs)¶
Bases:
Protocol
Protocol for unified cache interface.
- close() None ¶
- flushdb() None ¶
- get(key: str) str | None ¶
- info() dict[str, int | str] ¶
- set(key: str, value: str) None ¶
- class mex.backend.cache.connector.LocalCache¶
Bases:
dict
[str
,str
]Fallback key/value store based on a local dict.
- close() None ¶
Close the local cache.
- flushdb() None ¶
Clear the local cache.
- info() dict[str, int | str] ¶
Return basic info for local cache usage.
- set(key: str, value: str) None ¶
Store the given value for the given key.