ahvn.cache.db_cache module¶
Database-based cache backend.
- class ahvn.cache.db_cache.DatabaseCache(provider=None, database=None, exclude=None, *args, **kwargs)[源代码]¶
基类:
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)[源代码]¶
Initialization.
- 参数:
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__()[源代码]¶
Get the number of cache entries.
- 返回:
The number of entries in the cache.
- 返回类型:
- 抛出:
DatabaseError -- If the count is not correctly returned from SQL.