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.38 kB
import { Cache } from '@epic-web/cachified'; import { Database } from 'sqlite3'; /** * 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 sqlite3 Database instance * @param tableName - Name of the cache table to create */ export declare function createSqlite3CacheTable(database: Database, tableName: string): Promise<void>; /** * Creates a sqlite3 cache adapter for use with cachified * * @param options - {@linkcode CachifiedAdapterSqliteOptions} plus a database instance * @param options.database - The sqlite3 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 sqlite3 */ export declare function sqlite3CacheAdapter<Value = unknown>(options: CachifiedAdapterSqliteOptions & { database: Database; }): Cache<Value>; export { }