cuda.core.utils.SQLiteProgramCache#

class cuda.core.utils.SQLiteProgramCache(
path: str | PathLike,
*,
max_size_bytes: int | None = None,
)#

Persistent program cache backed by a single sqlite3 database file.

Suitable for single-process workflows. Multiple processes can share the file (sqlite3 WAL mode serialises writes), but FileStreamProgramCache is the recommended choice for concurrent workers.

Parameters:
  • path – Filesystem path to the sqlite3 database. The parent directory is created if missing.

  • max_size_bytes – Optional cap on the sum of stored payload sizes. When that total exceeds the cap, the least-recently-used entries are evicted until the logical total is at or below the cap; None means unbounded. Real on-disk usage tracks the logical total at quiescent points: WAL frames and freed pages are reclaimed opportunistically via wal_checkpoint(TRUNCATE) + VACUUM after each eviction, but sqlite3 skips both under active readers or writers. With concurrent access, the on-disk file can grow above the cap until readers release; FileStreamProgramCache is the right backend for multi-process workloads with strict on-disk bounds.

Methods

__init__(
path: str | PathLike,
*,
max_size_bytes: int | None = None,
) None#
clear() None#

Remove every entry from the cache.

close() None#

Release backend resources. No-op by default.

get(
key: bytes | str,
default: ObjectCode | None = None,
) ObjectCode | None#

Return self[key] or default if absent.