ahvn.cache.db_cache module¶
Database-based cache backend.
- class ahvn.cache.db_cache.DatabaseCache(provider=None, database=None, exclude=None, *args, **kwargs)[source]¶
Bases:
BaseCacheAn implementation of BaseCache that stores data in a database table using JSON columns. Each cache entry is stored as a row with a string key and JSON data using the CacheORMEntity model.
- __init__(provider=None, database=None, exclude=None, *args, **kwargs)[source]¶
Initialization.
- Parameters:
provider (str) – Database provider (‘sqlite’, ‘pg’, ‘duckdb’, etc.).
database (str) – Database name or path (‘:memory:’ for in-memory).
exclude (Optional[Iterable[str]]) – Keys to exclude from inputs when creating cache entries.
*args – Additional positional arguments.
**kwargs – Additional keyword arguments for database connection.
- __len__()[source]¶
Get the number of cache entries.
- Returns:
The number of entries in the cache.
- Return type:
- Raises:
DatabaseError – If the count is not correctly returned from SQL.