← All packages

@lacspace/cache

v1.0.2App & Utils Kit0 deps

A tiny in-memory cache — LRU eviction, per-entry TTL and stale-while-revalidate, plus wrap()/memoize() to cache any async function with in-flight de-duplication. Zero-dependency, isomorphic.

npm i @lacspace/cache

Usage

cache.ts
import { createCache } from "@lacspace/cache";

const cache = createCache<User>({ max: 500, ttl: 60_000 });

cache.set("a", user);
cache.get("a");        // user  (or undefined once expired)
cache.has("a");        // true
cache.size;            // 1

Exports 2

createCachememoize

Keywords

cachelrulru-cachettlstale-while-revalidateswr

More in App & Utils Kit