UNPKG

simple-in-memory-cache

Version:

A simple in-memory cache, for nodejs and the browser, with time based expiration policies.

18 lines (17 loc) 534 B
import { UniDuration } from '@ehmpathy/uni-time'; export interface SimpleInMemoryCache<T> { get: (key: string) => T | undefined; set: (key: string, value: T, options?: { expiration?: UniDuration | null; }) => void; keys: () => string[]; } export interface SimpleInMemoryCacheState<T> { [index: string]: { value: T; expiresAtMse: number; }; } export declare const createCache: <T>({ expiration: defaultExpiration, }?: { expiration?: UniDuration | null; }) => SimpleInMemoryCache<T>;