cachified-adapter-sqlite
Version:
SQLite adapter for @epic-web/cachified. Compatible with better-sqlite3, sqlite, sqlite3, node:sqlite, and bun:sqlite.
108 lines (97 loc) • 4.46 kB
TypeScript
import { Cache } from '@epic-web/cachified';
import { Database } from 'sqlite3';
import { Database as Database_2 } from 'sqlite';
import { Database as Database_3 } from 'better-sqlite3';
import { Database as Database_4 } from 'bun:sqlite';
/**
* Creates a better-sqlite3 cache adapter for use with cachified
*
* @param options - {@linkcode CachifiedAdapterSqliteOptions} plus a database instance
* @param options.database - The better-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 better-sqlite3
*/
export declare function betterSqlite3CacheAdapter<Value = unknown>(options: CachifiedAdapterSqliteOptions & {
database: Database_3;
}): Cache<Value>;
/**
* Creates a Bun SQLite cache adapter for use with cachified
*
* @param options - {@linkcode CachifiedAdapterSqliteOptions} plus a database instance
* @param options.database - The Bun 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 Bun's SQLite driver
*/
export declare function bunSqliteCacheAdapter<Value = unknown>(options: CachifiedAdapterSqliteOptions & {
database: Database_4;
}): Cache<Value>;
/**
* Common options for all SQLite-based cache adapters
*/
export 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 better-sqlite3 Database instance
* @param tableName - Name of the cache table to create
*/
export declare function createBetterSqlite3CacheTable(database: Database_3, tableName: string): void;
/**
* Creates a cache table in the SQLite database if it doesn't already exist
*
* @param database - The Bun SQLite Database instance
* @param tableName - Name of the cache table to create
*/
export declare function createBunSqliteCacheTable(database: Database_4, tableName: string): void;
/**
* 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 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_2, 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>;
/**
* 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_2;
}): Cache<Value>;
export { }