Simple key-value storage with support for multiple backends. Current stable version is 5.6.0. Keyv provides a unified interface for various storage backends like Redis, MongoDB, SQLite, and more. It supports TTL, event-driven invalidation, and adapter-based architecture. Compared to alternatives like `node-cache`, Keyv offers pluggable storage backends while maintaining a consistent API. The package is actively maintained and includes TypeScript definitions.
npm install keyvNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes Keyv with a Redis backend, sets and retrieves a value, then deletes it.
Use `@keyv/redis` or other adapter packages directly. Previously `KeyvRedis` was exported from Keyv itself.
Upgrade to v5 and ensure custom stores implement `get`, `set`, `delete`, `clear`, `has` and `iterator` methods returning promises.
Always pass TTL in milliseconds. Use `60000` for 1 minute, not `60`.
Retrieved objects are clones. Mutating them after `get` will not update the stored value.
Use separate instances or manually prefix keys. Namespace was removed in v5.
Use `import Keyv from 'keyv'` (ESM) or `const Keyv = require('keyv')` (CommonJS).Ensure store implements `get`, `set`, `delete`, `clear`, `has`, `iterator` methods.
Install and import `@keyv/redis` or other adapter package.