The Principal Dev – Masterclass for Tech Leads

The Principal Dev – Masterclass for Tech Leads28-29 May

Join

keyv

Simple key-value storage with support for multiple backends

build bun browser codecov npm npm

Getting Started

Keyv provides a consistent interface for key-value storage across multiple backends via storage adapters. It supports TTL-based expiry, making it suitable as a cache or a persistent key-value store.

Install Keyv:

npm install keyv

By default everything is stored in memory. You can optionally install a storage adapter for persistent backends:

npm install @keyv/redis

Use it:

import Keyv from 'keyv';

const keyv = new Keyv();
await keyv.set('foo', 'bar');
await keyv.get('foo'); // 'bar'

For the full API documentation, see the Keyv README.

Project Structure

This monorepo is organized into categorized directories:

core/             Core packages
  keyv/             Main Keyv library
  test-suite/       Shared test suite for API compliance
  bigmap/           Scalable in-memory Map
serialization/    Serialization packages
  superjson/        SuperJSON serializer (@keyv/serialize-superjson)
  msgpackr/         MessagePack serializer (@keyv/serialize-msgpackr)
compression/      Compression adapters
  compress-brotli/
  compress-gzip/
  compress-lz4/
storage/          Storage adapters
  redis/  postgres/  mysql/  mongo/  sqlite/
  memcache/  etcd/  valkey/  dynamo/
website/          Documentation website (keyv.org)

Packages

Storage Adapters

Compression Adapters

Serialization

The default serializer (KeyvJsonSerializer) is built into the core keyv package. Alternative serializers are available as separate packages:

Third-party Storage Adapters

We love the community and the third-party storage adapters they have built. They enable Keyv to be used with even more backends and use cases.

View the complete list of third-party storage adapters and learn how to build your own at https://keyv.org/docs/third-party-storage-adapters/

Contributing

We welcome contributions! Here are some ways to get involved:

Keyv v5 to v6

We are actively working on Keyv v6, which includes several major changes such as improved TypeScript support, enhanced hooks system, and streamlined storage adapter interfaces. You can follow along with the development and see the full migration guide at https://keyv.org/docs/keyv-v5-to-v6

No major functionality will be added to Keyv v5. Only maintenance and security fixes will be applied going forward.

License

MIT © Jared Wray

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.