UNPKG

cachified-adapter-sqlite

Version:

SQLite adapter for @epic-web/cachified. Compatible with better-sqlite3, sqlite, sqlite3, node:sqlite, and bun:sqlite.

39 lines (34 loc) 1.42 kB
import { Cache } from '@epic-web/cachified'; import { DatabaseSync } from 'node:sqlite'; /** * Common options for all SQLite-based cache adapters */ declare type CachifiedAdapterSqliteOptions = { /** The name of the table to store cache entries */ tableName: string; /** Optional prefix to namespace cache keys */ keyPrefix?: string; /** Cache adapter name */ name?: string; }; /** * Creates a cache table in the SQLite database if it doesn't already exist * * @param database - The Node SQLite Database instance * @param tableName - Name of the cache table to create */ export declare function createNodeSqliteCacheTable(database: DatabaseSync, tableName: string): void; /** * Creates a `node:sqlite` cache adapter for use with cachified * * @param options - {@linkcode CachifiedAdapterSqliteOptions} plus a database instance * @param options.database - The Node SQLite database instance * @param options.tableName - Name of the table to store cache entries * @param options.keyPrefix - Optional prefix to namespace cache keys * @param options.name - Optional name for the cache adapter * @returns A Cache instance that stores data in SQLite using Node's SQLite driver */ export declare function nodeSqliteCacheAdapter<Value = unknown>(options: CachifiedAdapterSqliteOptions & { database: DatabaseSync; }): Cache<Value>; export { }