/** * DB Tier Storage Implementation * Uses SQLite (better-sqlite3) for cold data storage * Requirements: 2.3 */ import { KeyMetadata } from '../types/index.js'; import { StorageTier, TierConfig } from './StorageTier.js'; /** * Database schema: * CREATE TABLE cache_entries ( * key VARCHAR(512) PRIMARY KEY, * value BLOB NOT NULL, * expires_at INTEGER, * created_at INTEGER NOT NULL, * access_count INTEGER DEFAULT 0, * last_access INTEGER * ); */ /** * DBTier implements the StorageTier interface using SQLite. * This is the persistent tier for cold data that is rarely accessed. */ export declare class DBTier implements StorageTier { private db; private usedBytes; private capacityBytes; private isOpen; private storagePath; /** * Calculate the size in bytes of a key-value entry */ private calculateEntrySize; /** * Initialize the database schema */ private initializeSchema; /** * Check if a value is expired based on expires_at timestamp */ private isExpired; /** * Retrieve a value by key */ get(key: string): Promise; /** * Store a key-value pair with metadata */ set(key: string, value: Buffer, metadata: KeyMetadata): Promise; /** * Delete a key from the tier */ delete(key: string): Promise; /** * Check if a key exists in this tier */ exists(key: string): Promise; /** * Retrieve multiple values by keys (bulk operation) */ mget(keys: string[]): Promise>; /** * Synchronous get for internal use */ private getSync; /** * Store multiple key-value pairs (bulk operation) * Uses SQLite transaction for efficiency */ mset(entries: Map, metadata: KeyMetadata): Promise; /** * Get the current used bytes in this tier */ getUsedBytes(): number; /** * Get the maximum capacity in bytes for this tier */ getCapacityBytes(): number; /** * Iterate over keys in this tier, optionally filtered by pattern * Pattern supports simple glob matching with * wildcard */ keys(pattern?: string): AsyncIterableIterator; /** * Simple glob pattern matching with * wildcard */ private matchPattern; /** * Initialize and open the storage tier */ open(config: TierConfig): Promise; /** * Close the storage tier and release resources */ close(): Promise; /** * Flush any pending writes to persistent storage * SQLite handles this automatically with WAL mode */ flush(): Promise; } //# sourceMappingURL=DBTier.d.ts.map