Keyv
Unified key-value storage interface that adapts to multiple backends such as Map, Redis, SQLite and others.
Official Documentation ↗keyv v5.x(ESM)/ Node 18 LTS. Check the official docs for the latest API surface.Installation
npm install keyvpnpm add keyvyarn add keyvMethods
No methods match this filter.
Overview
Keyv provides one async API over many storage engines. Swap Map, Redis, SQLite or others without changing call sites, and share a TTL and namespace model across them.
Core Methods
Construct with a store and options, then use get, set, delete and clear. TTL is expressed in milliseconds, and iteration helpers let you list matching keys on backends that support it.
Usage Notes
Use an in-memory store in tests and a network store in production, keeping the same code path. Set a namespace per concern so a shared backend stays organized.
Common Pitfalls
A network-backed store adds latency and failure modes, so handle errors on the connection. Not all adapters support every feature such as iteration, and JSON serialization loses types like Date without custom codecs.
Security notes
Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://cdn.jsdelivr.net/gh/jaredwray/keyv@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:50:37.967Z.
- Only maintenance and security fixes will be applied going forward. (https://cdn.jsdelivr.net/gh/jaredwray/keyv@latest/README.md)
FAQ
- What happens without an explicit store?
- Keyv falls back to an in-memory Map, which is fine for development or tests but does not persist and is not shared across processes.
- How is data serialized?
- Values are JSON serialized by default, and a custom serialize/deserialize pair can be configured for other formats such as MessagePack.
- How do namespaces help?
- A namespace prefixes keys so different parts of an app can share one backend without collisions, which is useful when reusing a single Redis instance.
Report a problem with this API docOpens a pre-filled issue on GitHub.