UNPKG

hybrid-disk-cache

Version:

A hybrid disk cache utilize both the database and the file system.

23 lines (22 loc) 673 B
/// <reference types="node" /> import { Database } from 'better-sqlite3'; declare type CacheStatus = 'hit' | 'stale' | 'miss'; export interface CacheOptions { path?: string; ttl?: number; tbd?: number; } declare class Cache { db: Database; ttl: number; tbd: number; path: string; constructor({ path, ttl, tbd }?: CacheOptions); set(key: string, value: Buffer, ttl?: number): Promise<void>; get(key: string, defaultValue?: Buffer): Promise<Buffer | undefined>; has(key: string): Promise<CacheStatus>; del(key: string): Promise<void>; _delFile(filename: string): void; purge(): Promise<number>; } export default Cache;