db
¶
DBCache
¶
DBCache(
db_path: str = "cache.db",
max_size: Optional[int] = None,
time_to_live: Optional[int] = None,
cleanup_interval: Optional[int] = None,
)
Bases: DBCacheBase
SQLite-based caching implementation.
Parameters:
-
db_path
(str
, default:'cache.db'
) –Path to the SQLite database file
Source code in src/appl/caching/db.py
connect
¶
connect() -> Connection
Create and return a database connection.
Returns:
-
Connection
–sqlite3.Connection: Database connection object
Source code in src/appl/caching/db.py
find
¶
Find a value in the cache by key.
Parameters:
-
key
(str
) –Cache key to look up
Returns:
Source code in src/appl/caching/db.py
insert
¶
Insert a value to the cache.
Parameters:
Source code in src/appl/caching/db.py
add_to_cache
¶
add_to_cache(
args: Dict[str, Any],
value: ModelResponse,
cache: Optional[DBCacheBase] = None,
) -> None
Add a value to the LLM cache.
Source code in src/appl/caching/db.py
find_in_cache
¶
find_in_cache(
args: Dict[str, Any],
cache: Optional[DBCacheBase] = None,
) -> Optional[ModelResponse]
Find a value in the LLM cache by key.
Parameters:
-
args
(Dict[str, Any]
) –The arguments of the completion.
-
cache
(Optional[DBCacheBase]
, default:None
) –The cache to search in. Defaults to the global LLM cache.
Returns:
-
Optional[ModelResponse]
–The completion result if found, otherwise None.