TinyCache is a minimal in-memory cache library for Node.js and the browser (~1.5 KB minified). Current stable version is 1.1.2. It provides a simple key-value store with optional TTL expiration, cache size/memory size tracking, hit/miss counters, and a shared singleton cache. The API is straightforward, inspired by node-cache but smaller in footprint. Heavier alternatives include node-cache or lru-cache which offer more features like LRU eviction and persistent backends. TinyCache is ideal for lightweight caching needs where simplicity and size are priorities.
npm install tinycacheNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creation, put/get with TTL, shared cache, deletion, clearing, and stats.
Access as properties: cache.size, cache.memsize, cache.hits, cache.misses.
Use time > 0 for expiry. To store without expiry, omit time argument.
Always provide a key argument to get(). For debugging, explicitly use cache.get() only when intended.
Consider migrating to actively maintained alternatives like node-cache or lru-cache for new projects.
Use cache.size (no parentheses).
Run npm install js-sizeof or npm install tinycache (it should install as a dependency).
Use import TinyCache from 'tinycache' in ESM, or const TinyCache = require('tinycache') in CJS.Use import { shared } from 'tinycache'.