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