UNPKG

@dephub/cache

Version:

Simple file-based cache with persistent storage for Node.js applications

25 lines (24 loc) 864 B
import { CacheValue } from './types.js'; /** * Synchronous in-memory cache with runtime type validation. * * Extends Map<string, CacheValue> with value type enforcement on set operations. * All operations are synchronous, unlike FileCache which is asynchronous. * * @example * const cache = new MemoryCache(); * cache.set('key', 'value'); // Synchronous * const value = cache.get('key'); // Synchronous */ export declare class MemoryCache extends Map<string, CacheValue> { /** * Sets a value in the cache. * * @param key - Cache key (must be a string) * @param value - Value to store (string, number, or boolean) * @returns The cache instance for chaining * @throws {Error} If key is not a string * @throws {Error} If value is not string, number, or boolean */ set(key: string, value: CacheValue): this; }