UNPKG

multi-layers-cache

Version:

A very simple multi layers cache.

33 lines (32 loc) 702 B
import { Cache } from './types'; interface Options { max?: number; maxAge?: number; /** * Return the the stale on getting expired item. */ stale?: boolean; } export declare class LRUCache<K, V> extends Map { max: number; maxAge: number; stale: boolean; constructor(opts?: Options | number); peek(key: K): any; set(key: K, content: V, maxAge?: number): this; /** * * @param key * @param mut Update the ttl * @returns */ get(key: K, mut?: boolean): any; } interface LRUOption { /** * Max items in the map. */ maxItems?: number; } export declare function newLRUCache(opts?: LRUOption): Cache; export {};