The type of metadata to store alongside cached values. Defaults to Record<PropertyKey, unknown>
Creates a new SQLiteCacheStore instance.
Configuration options for the SQLite cache store
The filename for the SQLite database
The timeout value for database operations
Maximum number of entries allowed in the cache (must be non-negative integer)
Maximum size of a single cache entry in bytes (must be non-negative integer < 2GB)
The constructor initializes the SQLite database with the following optimizations:
It also creates necessary tables and indexes for cache operations and prepares SQL statements for common operations like get, update, insert, delete, and count.
Gets the total number of entries in the cache store.
The total count of cache entries
Closes the SQLite database connection. This method should be called when the cache store is no longer needed to free up resources.
Removes an entry from the SQLite cache store by its key.
The key of the cache entry to delete
Retrieves a cached value and its associated metadata by key
The unique identifier to lookup in the cache
An object containing the cached value as a Buffer, metadata, or undefined if the key doesn't exist in the cache
Sets a value in the SQLite cache store with an optional TTL and metadata.
The key to store the value under
The value to store. Must be a string or Buffer
Optional metadata to store with the value
Time-to-live in milliseconds. 0 means no expiration
A SQLite-based cache store implementation that provides persistent key-value storage with metadata.
This class implements a cache mechanism using SQLite as the underlying storage engine, supporting features like TTL (Time To Live), metadata storage, and automatic pruning of expired or excess entries.
Example
Remarks
Throws
When invalid options are provided in the constructor
Throws
When invalid arguments are provided to set() method
Throws
When attempting to store entries larger than maxEntrySize