Exapedia / Tools / JavaScript caching libraries 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 Capabilities LRUCache Keyv FlatCache QuickLRU Cacheable CacheableMemory TTLCache FAQ Popularity LRUCache has the most monthly downloads in this comparison, at 3.1B .
Library Monthly downloads Stars Last release License LRUCache 3.1B
5.9K Sep 2026 BlueOak-1.0.0 Keyv 866.0M
Not on GitHub Oct 2026 MIT FlatCache 796.0M
Not on GitHub Jun 2026 MIT QuickLRU 238.8M
775 Nov 2026 MIT Cacheable 161.0M
Not on GitHub Jun 2026 MIT CacheableMemory 158.3M
Not on GitHub Jun 2026 MIT TTLCache 98.8M
Not on GitHub May 2026 BlueOak-1.0.0 Downloads: npm , last thirty days. Stars and releases: GitHub. Amber: no release in over a year.
Features compared Library LRU eviction Disk snapshots Async get/set LRUCache Built-in Unsupported Unsupported Keyv Via plugin Unsupported Built-in FlatCache Built-in Built-in Unsupported QuickLRU Built-in Unsupported Unsupported Cacheable Built-in Unsupported Built-in CacheableMemory Built-in Unsupported Unsupported TTLCache Unsupported Unsupported Unsupported Built-in Via plugin Not 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. $ npm install lru-cache@11.5.3 Copy
import { LRUCache } from 'lru-cache';
const cache = new LRUCache({ max: 1000 });
cache.set('key', 'value');
LRUCache examples From open-source projects on GitHub static fromUrl (giturl, opts) {
if (typeof giturl !== 'string') {
return
}
const key = giturl + JSON.stringify(opts || {})
if (!cache.has(key)) {
const hostArgs = fromUrl(giturl, opts, {
gitHosts: GitHost.#gitHosts,
protocols: GitHost.#protocols,
})
cache.set(key, hostArgs ? new GitHost(...hostArgs) : null)
}
return cache.get(key) ?? undefined
}
Show full example 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 $ npm install keyv@6.1.0 Copy
import { Keyv } from 'keyv';
const cache = new Keyv();
await cache.set('key', 'value');
Keyv examples From open-source projects on GitHub const get = async (options_: any) => {
await Promise.resolve();
const cacheEntry = options_.cache
? await this.cache.get(key)
: undefined;
if (cacheEntry === undefined && !options_.forceRefresh) {
makeRequest(options_);
return;
}
const policy = CachePolicy.fromObject(
(cacheEntry as CacheValue).cachePolicy,
);
if (
policy.satisfiesWithoutRevalidation(options_) &&
!options_.forceRefresh
) {
const headers = convertHeaders(policy.responseHeaders());
const bodyBuffer = (cacheEntry as CacheValue).body;
const body = Buffer.from(bodyBuffer as string);
const response: any = new Response({
statusCode: (cacheEntry as CacheValue).statusCode,
headers,
body,
url: (cacheEntry as CacheValue).url,
});
response.cachePolicy = policy;
response.fromCache = true;
ee.emit("response", response);
if (typeof callback === "function") {
callback(response);
}
} else if (
policy.satisfiesWithoutRevalidation(options_) &&
Date.now() >= policy.timeToLive() &&
options_.forceRefresh
) {
await this.cache.delete(key);
options_.headers = policy.revalidationHeaders(options_);
makeRequest(options_);
} else {
revalidate = cacheEntry;
options_.headers = policy.revalidationHeaders(options_);
makeRequest(options_);
}
};
Show full example 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 $ npm install flat-cache@6.1.23 Copy
import { FlatCache } from 'flat-cache';
const cache = new FlatCache();
cache.setKey('key', 'value');
cache.save();
FlatCache examples From open-source projects on GitHub async getFromCache(key) {
const hashedKey = this.getCacheFilePath(key);
try {
if (this.cacheType === 'flat-cache') {
const cachedData = this.cacheInstance.getKey(hashedKey);
if (cachedData && cachedData.ttl && Date.now() > cachedData.ttl) {
this.cacheInstance.removeKey(hashedKey);
this.cacheInstance.save(true);
return null;
}
return cachedData ? cachedData.data : null;
} else if (this.cacheType === 'cache-manager') {
if (
typeof this.cacheInstance?.store?.get !== 'function' &&
typeof this.cacheInstance?.get !== 'function'
) {
await this.loadCacheInstance();
}
if (typeof this.cacheInstance?.store?.get === 'function') {
return await this.cacheInstance.store.get(hashedKey);
} else if (typeof this.cacheInstance?.get === 'function') {
return await this.cacheInstance.get(hashedKey);
} else {
throw new CacheError('Cache manage not available');
}
} else if (this.cacheType === 'simple-cache') {
return await this.cacheInstance.getFromCache(hashedKey);
} else if (this.cacheType === 'memory-cache') {
return this.cacheInstance.get(hashedKey);
}
} catch (error) {
console.error(error);
return null;
}
}
Show full example 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. $ npm install quick-lru@8.0.0 Copy
import QuickLRU from 'quick-lru';
const cache = new QuickLRU({ maxSize: 1000 });
cache.set('key', 'value');
QuickLRU examples From open-source projects on GitHub function createLRUCache<T>(options: {maxSize: number}): SWRCache<T> {
const lru = new QuickLRU<string, {value: T}>(options)
return {
get(key: string) {
const entry = lru.get(key)
if (!entry) {
throw new Error(`Key not found in LRU cache: ${key}`)
}
return entry.value
},
set(key: string, value: T) {
lru.set(key, {value})
},
delete(key: string) {
lru.delete(key)
},
has(key: string) {
return lru.has(key)
},
}
}
Show full example 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 $ npm install cacheable@2.5.0 Copy
import { Cacheable } from 'cacheable';
const cache = new Cacheable();
await cache.set('key', 'value');
Cacheable examples From open-source projects on GitHub public async handle(ctx: Context, url: URL, meta?: Meta, allowLazy?: boolean): Promise<UrlResult[]> {
const extractor = this.extractors.find(extractor => !isExtractorDisabled(ctx.config, extractor) && extractor.supports(ctx, url));
if (!extractor) {
return [];
}
const normalizedUrl = extractor.normalize(url);
const cacheKey = this.determineCacheKey(ctx, extractor, normalizedUrl);
const storedDataRaw = await this.urlResultCache.getRaw<UrlResult[]>(cacheKey);
const expires = storedDataRaw?.expires;
if (storedDataRaw && expires) {
const ttl = expires - Date.now();
/* istanbul ignore if */
if (ttl > 0) {
return (storedDataRaw.value as UrlResult[]).map(urlResult => ({ ...urlResult, ttl, url: new URL(urlResult.url) }));
}
}
const lazyUrlResults = await this.lazyUrlResultCache.get<UrlResult[]>(normalizedUrl.href) ?? [];
/* istanbul ignore next */
if (
lazyUrlResults.length && allowLazy && !extractor.viaMediaFlowProxy
&& lazyUrlResults.every(urlResult => urlResult.format !== Format.hls) // related to Android issues, e.g. https://github.com/Stremio/stremio-bugs/issues/1574 or https://github.com/Stremio/stremio-bugs/issues/1579
) {
// generate lazy extract urls
return lazyUrlResults.map((urlResult, index) => {
const extractUrl = new URL(`${envGet('PROTOCOL')}:${envGet('HOST')}/extract/`);
extractUrl.searchParams.set('index', `${index}`);
extractUrl.searchParams.set('url', url.href);
return { ...urlResult, url: extractUrl };
});
}
this.logger.info(`Extract ${url} using ${extractor.id} extractor`, ctx);
const mergedMeta: Meta = { ...meta, ...lazyUrlResults[0]?.meta };
const urlResults = await extractor.extract(ctx, normalizedUrl, { extractorId: extractor.id, ...mergedMeta });
if (!Object.keys(mergedMeta).length || urlResults.some(urlResult => urlResult.error)) {
await this.urlResultCache.delete(cacheKey);
await this.lazyUrlResultCache.delete(normalizedUrl.href);
return urlResults;
}
const ttl = urlResults.length ? extractor.ttl : 43200000; // 12h
await this.urlResultCache.set<UrlResult[]>(cacheKey, urlResults, ttl);
if (extractor.id !== 'external') {
await this.lazyUrlResultCache.set<UrlResult[]>(normalizedUrl.href, urlResults, 2629800000); // 1 month
}
return urlResults;
};
Show full example 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 $ npm install @cacheable/memory@2.2.0 Copy
import { CacheableMemory } from '@cacheable/memory';
const cache = new CacheableMemory();
cache.set('key', 'value');
CacheableMemory examples From open-source projects on GitHub public constructor(logger: winston.Logger, extractors: Extractor[]) {
this.logger = logger;
this.extractors = extractors;
this.urlResultCache = new Cacheable({
nonBlocking: true,
primary: new Keyv({ store: new CacheableMemory({ lruSize: 1024 }) }),
secondary: createKeyvSqlite('extractor-cache'),
stats: true,
});
this.lazyUrlResultCache = new Cacheable({
nonBlocking: true,
primary: new Keyv({ store: new CacheableMemory({ lruSize: 1024 }) }),
secondary: createKeyvSqlite('extractor-lazy-cache'),
stats: true,
});
}
Show full example 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 $ npm install @isaacs/ttlcache@2.1.5 Copy
import { TTLCache } from '@isaacs/ttlcache';
const cache = new TTLCache({ max: 10000, ttl: 1000 });
cache.set('key', 'value');
FAQ Does QuickLRU enforce a strict maxSize entry count? Its target maxSize can be exceeded internally even though the reported size is capped.
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.
Claude Code Cursor Codex VS Code Devin Devin Desktop Gemini CLI OpenCode
Run in your terminal
claude plugin install exa@claude-plugins-official Copy Add to ~/.cursor/mcp.json
{
"mcpServers": {
"exa": {
"url": "https://mcp.exa.ai/mcp"
}
}
} Copy Open in your browser, then install the Exa plugin
https://chatgpt.com/plugins/exa Copy Add to .vscode/mcp.json
{
"servers": {
"exa": {
"type": "http",
"url": "https://mcp.exa.ai/mcp"
}
}
} Copy In Devin, open Customize, then MCPs, and add a custom HTTP server with this URL
https://mcp.exa.ai/mcp Copy Add to ~/.config/devin/mcp_config.json
{
"mcpServers": {
"exa": {
"serverUrl": "https://mcp.exa.ai/mcp"
}
}
} Copy Add to ~/.gemini/settings.json
{
"mcpServers": {
"exa": {
"httpUrl": "https://mcp.exa.ai/mcp"
}
}
} Copy Add to opencode.json
{
"mcp": {
"exa": {
"type": "remote",
"url": "https://mcp.exa.ai/mcp"
}
}
} Copy