Cacheable

High-performance layer 1 / layer 2 caching engine built on Keyv

Library
npm
v2.5.0
2,011 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
87 /100 Excellent
Development Activity 96
Maintenance 84
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
79 /100 Good
Architecture 80
Code Quality 82
Innovation 75
Learning Curve 78

Cacheable is a distributed caching library for Node.js built on top of the Keyv storage engine, providing simple layered (memory + remote) caching with an enterprise-grade feature set. It combines an in-memory LRU cache (CacheableMemory) as a fast primary layer with any Keyv-compatible secondary store (Redis, etc.), non-blocking writes, and a CacheSync pub/sub mechanism for keeping multiple instances consistent.

Part of the broader jaredwray/cacheable monorepo (which also ships cache-manager, cacheable-request, flat-cache, and other caching utilities), Cacheable is under active, regular maintenance with comprehensive test coverage and both ESM and CommonJS builds.

What You Get

  • Cacheable class combining a fast in-memory primary store with an optional remote secondary store
  • CacheableMemory - a standalone LRU cache with TTL/expiration support
  • Function memoization via wrap() and getOrSet() with stampede protection for sync and async functions
  • Hooks and events (before/after set, get, delete) to extend caching behavior
  • CacheSync for distributed cache invalidation across instances via pub/sub
  • Non-blocking secondary-store writes so remote latency doesn’t block reads/writes

Common Use Cases

  • Adding a fast in-memory layer in front of Redis to cut round-trips for hot keys
  • Memoizing expensive async function calls (e.g. DB queries) with automatic TTL
  • Keeping cache state consistent across multiple app instances via CacheSync
  • Tag-based invalidation of related cache entries after a data update
  • Building a resilient caching layer that degrades gracefully if the remote store is offline

Under The Hood

Architecture - The packages/cacheable module (within the jaredwray/cacheable pnpm monorepo) centers on a Cacheable class in src/index.ts that composes a primary Keyv instance (defaulting to CacheableMemory, an in-memory LRU store defined in src/memory.ts equivalents) with an optional secondary Keyv-compatible store; reads check primary then fall back to secondary, writes propagate to both non-blockingly, and sync.ts implements CacheSync, a pub/sub layer that broadcasts invalidations to keep multiple processes’ primary caches consistent.

Tech Stack - Written in TypeScript (97%+ of the monorepo), built with tsdown to emit both ESM (.mjs) and CommonJS (.cjs) outputs with generated .d.ts types, and depends on the keyv storage-adapter ecosystem (@keyv/redis, lru-cache) rather than hardcoding a specific backend, using pnpm workspaces to share tooling (biome for linting) across the monorepo’s ten-plus packages.

Code Quality - The monorepo enforces test coverage via Codecov badges and a GitHub Actions tests.yml workflow; the cacheable package itself is a relatively small, focused module (~2,200 lines across src/), and the monorepo’s shared CONTRIBUTING.md/AGENTS.md/CLAUDE.md files indicate deliberate conventions for contributors and AI coding agents alike.

API Design - The API is intentionally minimal - new Cacheable({secondary}) plus .get()/.set()/.delete() covers the common case, with TTL shorthand strings ('1h', '1d') reducing boilerplate, and wrap()/getOrSet() let existing functions be memoized without restructuring calling code; hooks and typed events provide an escape hatch for advanced use without complicating the base API.

Used by 15 apps in this directory

TypeScript
94%
AGPL 3.0

Laudspeaker

Automation · Marketing

2,629

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
45
Repo Health
66
Technical
62
Dependency
Built with
TypeScript 94%
Updated 3 months ago
TypeScript
92%
Other

n8n

Automation · No Code Platforms

208,437

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
62
Dependency
Built with
TypeScript 92%
Updated 6 days ago
TypeScript
99%
Other

NocoBase

Low Code Platforms · No Code Platforms

24,686

Open-source AI + no-code platform that lets coding agents and people collaborate to build business systems fast on proven infrastructure.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
TypeScript 99%
Updated 5 days ago
TypeScript
98%
MIT

Promptfoo

AI Development

26,358

An open-source CLI and library for evaluating and red-teaming LLM applications — replace trial-and-error prompt engineering with systematic evals, vulnerability scanning, and CI/CD integration.

View details
90
Repo Health
73
Technical
67
Dependency
Built with
TypeScript 98%
Updated 5 days ago
TypeScript
79%
MIT

Trench

Analytics · Data Engineering · Monitoring

1,665

Open-source event tracking infrastructure built on Kafka and ClickHouse that handles thousands of events per second on a single node, with full Segment API compatibility and no cookies.

View details
44
Repo Health
81
Technical
73
Dependency
Built with
TypeScript 79%
MDX 15%
Updated 6 months ago
TypeScript
84%
Other

twenty

CRM

59,615

The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.

View details
92
Repo Health
82
Technical
64
Dependency
Built with
TypeScript 84%
MDX 14%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers