npm / keyv
keyv
What changed in keyv 5 to 6, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
84 breaking5 deprecations23 new APIs and options1 performance10 behavior and defaults2 tooling14 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initkeyv 6124 changes
Breaking changes 76
AES-CBC is no longer accepted by the encryption packages.
A namespaced clear fails rather than wiping a store it cannot list; provide keys() or iterator(), or clear without a namespace.
Attaching an error listener makes failed calls return a fallback value; without one, failed calls reject.
The namespace separator option is now namespaceSeparator; keyPrefixSeparator is gone.
The namespace separator option is now namespaceSeparator; keySeparator is gone.
The package accepts only AES-GCM, AES-CCM, and ChaCha20-Poly1305 with base64, base64url, or hex output; AES-CBC is removed.
The package accepts only AES-GCM; AES-CBC is removed.
The @keyv/etcd store's lease property is removed; remove code that reads or assigns it.
Several adapters store keys beginning with <namespace>: as given instead of treating them as already prefixed.
Set this option to true on an etcd store without a namespace to restore whole-store clear() and iterator() behavior.
Redis clear matches the namespace literally rather than as a glob pattern.
Replacing the Redis client removes the old client's listeners.
Redis iterator matches the namespace literally rather than as a glob pattern.
Rejected memcache writes return false.
Writes fail when an encryption adapter is set and serialization is off; serialization remains on by default.
The Dynamo option is removed; use Keyv's ttl option for a default expiry.
Setting storeSize keeps every entry and no longer emits clear.
The option is removed; failed calls return a fallback value when an error listener is attached and reject when none is.
Dynamo keys written without a TTL no longer expire; set Keyv's ttl option for a default expiry.
Valkey clear removes only its own namespace, not namespaces that share its prefix.
Valkey reads return undefined, never null.
This alias for
onHookregisters a hook.Without a namespace, clear may remove more than the calling Keyv instance's entries; set a namespace when the backend is shared.
The export was removed.
Passing a connection string or
urioption no longer loads an adapter; Keyv quietly uses an in-memory store. Pass an adapter instead.Keyv no longer defaults to the
keyvnamespace or prefixes keys, so v5 data may appear missing unless the v5 namespace and storage layout are configured.Passing an array now returns a boolean array, matching
deleteMany; a single key still returns one boolean.The method now returns
boolean[]instead of a single boolean.Detects whether a value is compatible with Keyv.
Detects storage capabilities and identifies map-like stores.
The property has been removed.
The option has been removed.
Empty-string keys are rejected:
setanddeletereturnfalse, whilegetreturnsundefined.The v6 storage-adapter contract passes an absolute Unix timestamp in milliseconds to
setand inKeyvStorageEntryentries, instead of relative TTL values.The raw option is no longer supported; use
getRawinstead.Raw support was removed; use
getManyRawto retrieve raw values.With the default
checkExpiredbehavior enabled,hasreads and decodes the entry to skip expired values.Hook payloads now carry the key passed by the caller rather than the prefixed key.
Keyv now extends Hookified directly, replacing its custom event and hook manager classes.
The property now exposes a
Map<string, IHook[]>instead of the former handlers property.Hooks are awaited, so asynchronous hooks delay the operation they belong to.
The type now comes from
hookified.Custom asynchronous stores need
iterator()for Keyv to find entries belonging to a namespace during clear.Now a built-in async generator method requiring no arguments; namespace handling is automatic, and expired entries are filtered and deleted during iteration.
The type was removed.
The old @keyv/redis separator name is no longer supported; JavaScript ignores the option and TypeScript reports it as an error.
Custom synchronous Map-like stores need
keys()for Keyv to find entries belonging to a namespace during clear.Without a namespace, clear() and iterator() now touch only entries Keyv wrote without a namespace.
The adapter switches from memjs to memcache. Update any memjs-specific client options; the adapter API is unchanged for default settings.
clear() invalidates only the store's own namespace entries instead of flushing the whole Memcached server.
The package is not part of v6; remove it from project dependencies when migrating.
The package has no default export; named suites take Vitest's
testoritfunction as the first argument, and suite names changed.For a Map or older adapter, returns the Keyv-created wrapper; the original object is available at
keyv.store.store.Compression adapters now implement an interface whose
compressanddecompressmethods take a string and resolve to a string; v5 compressed data cannot be read by v6.Renamed to
compressionTestSuite.setManynow usesKeyvEntry[]as its input type.Renamed to
keyvNamespaceTests.Storage adapters receive absolute
expiresinstead of relativettl.A Map now holds
{ value, expires }objects undernamespace::key, or the bare key without a namespace, rather than serialized strings underkeyv:key.Keyv normalizes missing values to
undefinedinstead of passing through adapter-specificnullvalues.Namespace handling moves to storage adapters; an adapter's namespace is retained when Keyv has none, while a namespace passed to Keyv takes precedence.
Adapters that join namespace and key use
::by default; configure this option to use another separator, such as:for v5 key layouts.Every v6 package requires Node.js 22.19 or later, so update runtimes, CI matrices, and pinned runtime versions.
Use this method instead of
keyv.hooks.addHandlerto register a hook.The property is removed from Keyv and the KeyvStorageAdapter interface; use direct property access instead.
Use this method with an event and handler object instead of
keyv.hooks.removeHandler.This option replaces
serializeanddeserializeand accepts an adapter withstringifyandparsemethods.Set the option to false to disable serialization.
The option is ignored in plain JavaScript and has no effect.
The method now accepts
KeyvEntry[]and returnsboolean[]instead of a single boolean.The @keyv/dynamo store's sixHoursInMilliseconds property is removed.
The v5 methods
hit(),miss(),set(),delete(), andhitsOrMisses()were removed;getManynow records a hit or miss per key.Symbols can no longer be stored; setting one emits an error and either rejects or returns
falsedepending on whether an error listener is attached.A TTL of zero or less means no TTL, and fractional TTLs are rounded up to the next millisecond.
Storage adapters no longer declare
ttlSupport; Keyv detects the store and wraps older adapters or synchronous Map-like stores as needed.The option and property are removed; Keyv no longer handles key prefixing.
Deprecations 5
Remains available as a deprecated alias of
KeyvValue.Keyv v5 enters maintenance mode; it will receive maintenance and security fixes but no major functionality.
Remains available as a deprecated alias of
KeyvCompressionAdapter.Hook names use the
before:andafter:convention; old PRE_/POST_ enum values remain deprecated but functional and emit a warning.Remains available as a deprecated alias of
KeyvStorageAdapter.
New APIs and options 17
Redis createKeyv accepts cluster and sentinel options.
Adapters that join the namespace and key accept namespaceSeparator, which defaults to ::.
A v6 storage adapter advertises the absolute-expiry contract with
capabilities.expires === true;keyvStorageCapability(this)builds the capability descriptor.Defaults to
true, so Keyv filters expired reads using the serialized envelope; set it tofalseto trust the backend and skip the extra decode on reads.Detects whether a compression adapter is compatible.
Detects whether an encryption adapter is compatible.
Detects whether a serialization adapter is compatible.
Keyv accepts an encryption adapter for values; encryption operates on serialized strings and requires serialization to be enabled.
Use this method instead of
getMany(keys, { raw: true })to access raw values.Use this method instead of
get(key, { raw: true })to access raw values.Adds a Node.js crypto encryption adapter supporting AES-GCM, AES-CCM, and ChaCha20-Poly1305.
Adds a Web Crypto API encryption adapter for browsers, Workers, and Deno.
Provides a high-performance binary MessagePack serialization adapter.
Provides a serialization adapter supporting Date, Map, Set, RegExp, URL, Error, and undefined values.
The built-in JSON serializer is the default and writes the same format as v5's
@keyv/serializeand v4'sjson-buffer.A new adapter handles advanced features for legacy storage adapters and Map-compatible stores.
Keyv exposes serialization for configuring serializers; the built-in KeyvJsonSerializer is the default, and serialization can be disabled or replaced with a custom adapter.
Performance 1
Intervals over 24.8 days no longer run cleanup every millisecond.
Behavior and default changes 10
Keyv uses a namespace set on the storage adapter when Keyv itself has none.
Memcache clear removes only the store's own entries; use noNamespaceAffectsAll on an unnamespaced store to flush the server.
The Redis connection timeout covers the handshake, and timed-out connects close their sockets.
Postgres deleteMany runs as one statement.
GridFS reads the newest revision, and delete removes every revision.
MySQL tables get a primary key on (namespace, id), and existing tables are migrated on connect.
Promise-based stores without async methods now go through KeyvBridgeAdapter.
Changing storeHashFunction now relocates entries under the new hash function without losing or duplicating them.
Keyv can now be used in browser environments with appropriate storage adapters.
Keys with whitespace or control characters, and keys over 250 bytes, are stored under a SHA-256 digest of the namespaced key.
Tooling 1
A published agent skill upgrades a project from Keyv v4 or v5 to v6.
Fixes and other changes 14
The etcd value envelope uses Keyv's JSON serializer so BigInt values round-trip.
The etcd value envelope uses Keyv's JSON serializer so Buffer values round-trip.
Without a namespace, etcd clear only touches entries Keyv wrote without a namespace.
The Redis helper stops reconnecting to a server that is down.
Fractional TTLs no longer fail writes.
Without a namespace, etcd iterator only touches entries Keyv wrote without a namespace.
Keys memcached cannot store now work.
Concurrent operations during the handshake share one connect instead of failing.
Redis missing values are undefined.
Etcd setMany reports failed writes as false.
Postgres SQL NULL reads as undefined.
The sqlite3 driver no longer hangs after a failed statement.
Valkey useSets works in cluster mode.
Keyv packages and adapters share a version number and are released together, simplifying compatible upgrades across the ecosystem.
keyv 515 changes
Breaking changes 8
Entries without a TTL omit
expires; check for undefined rather than null.The CommonJS class export changed from the module itself to named and default exports, so the v4 require form fails.
The package was removed; use Cacheable for offline fallbacks or a fast in-memory layer in front of a remote store.
The type now takes only the value type parameter; the options type parameter from v4 is no longer used.
The adapter uses the official
redisclient instead ofioredis;ioredisinstances and its exclusive options are no longer supported.Keyv v5 uses
@keyv/serializefor serialization; it writes the same format as v4.A failed write is now reported rather than always resolving true.
Pass a storage adapter directly or through the store option; connection strings silently fall back to an in-memory store instead of loading an adapter.
New APIs and options 6
Keyv ships an ESM build alongside its CommonJS build.
Keyv has its own event emitter and emits events for set, delete, clear, and error without third-party libraries.
Hooks support pre- and post-processing on set, get, getMany, and delete.
The method accepts an array of keys.
A new method was added for checking multiple keys.
Built-in statistics track hits, misses, sets, deletes, and errors.
Tooling 1
Keyv is written in TypeScript and ships its own types.