UNPKG

heapstash

Version:

HeapStash is a library that allows for easy caching in Node.js, with many advanced features such as TTL, maximum items in memory cache, external cache support, and more.

32 lines (31 loc) 1.12 kB
interface HeapStashSettings { idPrefix?: string; maxItems?: number; ttl?: number; } interface ActionSettings { internalCacheOnly?: boolean; } declare type GetSettings = ActionSettings; interface PutSettings extends ActionSettings { ttl?: number | false; pluginTTL?: number | false; } declare type FetchSettings = PutSettings; declare type RemoveSettings = ActionSettings; declare type ClearSettings = ActionSettings; declare class HeapStash { settings: HeapStashSettings; plugins: any[]; _: any; static Plugin: typeof Plugin; constructor(settings?: HeapStashSettings); get(id: string, settings?: GetSettings): Promise<any>; fetch(id: string, retrieveFunction: (id: string) => Promise<any>): Promise<any>; fetch(id: string, settings: FetchSettings, retrieveFunction: (id: string) => Promise<any>): Promise<any>; put(id: string | string[], item: any, settings?: PutSettings): Promise<void>; remove(id: string, settings?: RemoveSettings): Promise<void>; clear(settings?: ClearSettings): Promise<void>; } import Plugin from "./plugin"; export = HeapStash;