JavaScript caching libraries

Updated Nov 2026

JavaScript caching libraries keep computed or fetched results in memory or storage for reuse. Each cache evicts entries once they pass a limit on count, total size, or time to live. These libraries hold the API responses, rendered fragments, and database results that servers, build tools, and CLIs would otherwise recompute.

Popularity

LRUCache has the most monthly downloads in this comparison, at 3.1B.

LibraryMonthly downloadsStarsLast releaseLicense
LRUCache
3.1B
5.9KSep 2026BlueOak-1.0.0
Keyv
866.0M
Not on GitHubOct 2026MIT
FlatCache
796.0M
Not on GitHubJun 2026MIT
QuickLRU
238.8M
775Nov 2026MIT
Cacheable
161.0M
Not on GitHubJun 2026MIT
CacheableMemory
158.3M
Not on GitHubJun 2026MIT
TTLCache
98.8M
Not on GitHubMay 2026BlueOak-1.0.0
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryLRU evictionDisk snapshotsAsync get/set
LRUCacheBuilt-inUnsupportedUnsupported
KeyvVia pluginUnsupportedBuilt-in
FlatCacheBuilt-inBuilt-inUnsupported
QuickLRUBuilt-inUnsupportedUnsupported
CacheableBuilt-inUnsupportedBuilt-in
CacheableMemoryBuilt-inUnsupportedUnsupported
TTLCacheUnsupportedUnsupportedUnsupported
Built-inVia pluginNot supported

Libraries and code examples

Stores recently used entries with configurable size bounds, expiration, and asynchronous loading.

Downloads / mo
3.1B
Stars
5.9K
Last release
11.5.3
License
BlueOak-1.0.0

Strengths

  • Bounds the entry count. Set max to retain a fixed number of recently accessed entries.
  • Loads values asynchronously. Set fetchMethod and call fetch for asynchronous cache loading.

Limitations

  • Expired entries wait for access. Enable ttlAutopurge when stale entries need proactive removal.
  • Undefined values are not stored. Use a sentinel when undefined is a meaningful cached result.

Quickstart

From README.md
$ npm install lru-cache@11.5.3
import { LRUCache } from 'lru-cache';

const cache = new LRUCache({ max: 1000 });
cache.set('key', 'value');

LRUCache examples

From open-source projects on GitHub

Stores key-value pairs with namespaces and TTL behind an async API, in memory or through storage adapters.

Downloads / mo
866.0M
Last release
6.1.0
License
MIT

Quickstart

From README.md
$ npm install keyv@6.1.0
import { Keyv } from 'keyv';

const cache = new Keyv();
await cache.set('key', 'value');

Keyv examples

From open-source projects on GitHub

Caches values in memory and saves them to a file, with TTL and LRU controls.

Downloads / mo
796.0M
Last release
6.1.23
License
MIT

Quickstart

From README.md
$ npm install flat-cache@6.1.23
import { FlatCache } from 'flat-cache';

const cache = new FlatCache();
cache.setKey('key', 'value');
cache.save();

FlatCache examples

From open-source projects on GitHub

Provides a Map-based in-memory cache with approximate LRU eviction and optional expiration.

Downloads / mo
238.8M
Stars
775
Last release
8.0.0
License
MIT

Strengths

  • Fits Map-based application code. Use a Map subclass with familiar cache access methods.
  • Supports per-entry expiration. Set maxAge globally or specify expiration for individual entries.

Limitations

  • Size can exceed the target. Stored entries can exceed maxSize before batch eviction.
  • Expired entries are removed lazily. Removal waits for a read, iteration, or eviction.

Quickstart

From readme.md
$ npm install quick-lru@8.0.0
import QuickLRU from 'quick-lru';

const cache = new QuickLRU({ maxSize: 1000 });
cache.set('key', 'value');

QuickLRU examples

From open-source projects on GitHub

Coordinates a primary and a secondary cache built on Keyv, with TTL, tags, and statistics.

Downloads / mo
161.0M
Last release
2.5.0
License
MIT

Quickstart

From README.md
$ npm install cacheable@2.5.0
import { Cacheable } from 'cacheable';

const cache = new Cacheable();
await cache.set('key', 'value');

Cacheable examples

From open-source projects on GitHub

CacheableMemory

Keeps values in a synchronous in-memory store with an optional LRU size limit and TTL expiry.

Downloads / mo
158.3M
Last release
2.2.0
License
MIT

Quickstart

From README.md
$ npm install @cacheable/memory@2.2.0
import { CacheableMemory } from '@cacheable/memory';

const cache = new CacheableMemory();
cache.set('key', 'value');

CacheableMemory examples

From open-source projects on GitHub

Expires every entry after its TTL and evicts the soonest-expiring entries when the cache is full.

Downloads / mo
98.8M
Last release
2.1.5
License
BlueOak-1.0.0

Quickstart

From README.md
$ npm install @isaacs/ttlcache@2.1.5
import { TTLCache } from '@isaacs/ttlcache';

const cache = new TTLCache({ max: 10000, ttl: 1000 });
cache.set('key', 'value');

FAQ

An LRU (least recently used) cache keeps a bounded number of entries and evicts the entry read longest ago when it fills. LRUCache and QuickLRU work this way, while TTLCache evicts the soonest-expiring entries instead.

lru-cache removes expired values when they are read, unless ttlAutopurge enables preemptive deletion. quick-lru removes expired values lazily on reads, iteration, or eviction.

Its target maxSize can be exceeded internally even though the reported size is capped.

No. Storing undefined removes the key. A sentinel value can stand in for an intentionally empty result.

Its fetchMethod option supplies the asynchronous cache.fetch workflow.

Keyv keeps data in an in-memory Map by default and reaches Redis or other databases through storage adapters.

For coding agents

Found your caching library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official