UNPKG

transitory

Version:

In-memory cache with high hit rates via LFU eviction. Supports time-based expiration, automatic loading and metrics.

22 lines (21 loc) 778 B
import { Cache } from './Cache'; import { KeyType } from './KeyType'; import { Metrics } from './metrics/Metrics'; /** * Abstract class for all cache implementations. This exists so that its * possible to use instanceof with caches like: `obj instanceof AbstractCache`. */ export declare abstract class AbstractCache<K extends KeyType, V> implements Cache<K, V> { abstract maxSize: number; abstract size: number; abstract weightedSize: number; abstract set(key: K, value: V): V | null; abstract getIfPresent(key: K): V | null; abstract peek(key: K): V | null; abstract has(key: K): boolean; abstract delete(key: K): V | null; abstract clear(): void; abstract keys(): K[]; abstract cleanUp(): void; abstract metrics: Metrics; }