UNPKG

runtime-memory-cache

Version:

A lightweight, high-performance in-memory cache for Node.js with TTL support, configurable eviction policies (FIFO/LRU), statistics tracking, and zero dependencies.

44 lines (43 loc) 904 B
/** * Internal cache entry structure */ export type CacheEntry = { value: any; expiresAt?: number; createdAt: number; lastAccessedAt: number; }; /** * Eviction policy options */ export type EvictionPolicy = 'FIFO' | 'LRU'; /** * Memory usage information */ export interface MemoryUsage { estimatedBytes: number; averageBytesPerEntry: number; } /** * Cache statistics interface */ export interface CacheStats { hits: number; misses: number; size: number; maxSize: number; evictions: number; } /** * Cache configuration options */ export interface CacheOptions { /** Time to live in milliseconds */ ttl?: number; /** Maximum number of entries allowed in cache */ maxSize?: number; /** Enable statistics tracking */ enableStats?: boolean; /** Eviction policy - FIFO (default) or LRU */ evictionPolicy?: EvictionPolicy; }