MCPcopy
hub / github.com/jaredwray/keyv

github.com/jaredwray/keyv @main sqlite

repository ↗ · DeepWiki ↗
769 symbols 2,647 edges 191 files 414 documented · 54%
README

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/  cloudflare-kv/
website/          Documentation website (keyv.org)

Packages

  • keyv - Simple key-value storage with support for multiple backends
  • test-suite - Test suite for Keyv API compliance
  • bigmap - Scalable in-memory Map

Storage Adapters

  • cloudflare-kv - Cloudflare Workers KV storage adapter
  • dynamo - DynamoDB storage adapter
  • etcd - Etcd storage adapter
  • memcache - Memcache storage adapter
  • mongo - MongoDB storage adapter
  • mysql - MySQL/MariaDB storage adapter
  • postgres - PostgreSQL storage adapter
  • redis - Redis storage adapter
  • sqlite - SQLite storage adapter
  • valkey - Valkey (Open Source Redis) storage adapter

Compression Adapters

Serialization

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

  • serialize-superjson - SuperJSON serializer with Date, Map, Set, BigInt support (@keyv/serialize-superjson)
  • serialize-msgpackr - High-performance MessagePack serializer (@keyv/serialize-msgpackr)

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:

  • Pull Requests - Fork the repo, make your changes, run pnpm test, and open a PR. See CONTRIBUTING.md for detailed instructions.
  • Issues - Report bugs or request features by opening an issue. For bugs, include replication steps and error messages.
  • Questions - Create an issue with the label "question" and include relevant context.
  • Storage Adapter Requests - Create an issue with the label "storage adapter." Requests are given 30-60 days for community interest before being triaged.
  • Security - See our security policy for reporting vulnerabilities.
  • Code of Conduct - Please review our Code of Conduct.

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

Extension points exported contracts — how you extend this code

TaskData (Interface)
(no doc)
storage/sqlite/benchmark/utils.ts
BenchmarkResult (Interface)
(no doc)
storage/sqlite/benchmark/utils.ts

Core symbols most depended-on inside this repo

set
called by 403
core/keyv/src/keyv.ts
get
called by 279
core/keyv/src/keyv.ts
set
called by 134
storage/redis/src/index.ts
has
called by 86
core/keyv/src/keyv.ts
set
called by 82
storage/sqlite/src/index.ts
set
called by 74
storage/postgres/src/index.ts
store
called by 73
storage/etcd/test/test.ts
set
called by 65
storage/mongo/src/index.ts

Shape

Method 472
Function 222
Class 68
Enum 5
Interface 2

Languages

TypeScript100%

Modules by API surface

storage/redis/src/index.ts42 symbols
core/keyv/src/keyv.ts42 symbols
storage/sqlite/src/index.ts40 symbols
storage/etcd/src/client.ts40 symbols
storage/postgres/src/index.ts35 symbols
storage/mysql/src/index.ts29 symbols
storage/dynamo/src/index.ts29 symbols
storage/mongo/src/index.ts28 symbols
storage/etcd/src/index.ts28 symbols
storage/cloudflare-kv/src/index.ts28 symbols
storage/valkey/src/index.ts27 symbols
core/keyv/src/stats.ts25 symbols

Dependencies from manifests, versioned

@aws-sdk/client-dynamodb3.1075.0 · 1×
@aws-sdk/lib-dynamodb3.1075.0 · 1×
@biomejs/biome2.5.1 · 1×
@faker-js/faker10.5.0 · 1×
@keyv/compress-gzipworkspace:^ · 1×
@keyv/test-suiteworkspace:^ · 1×
@monstermann/tinybench-pretty-printer0.3.0 · 1×
@redis/client6.0.1 · 1×
@types/json-bigint1.0.4 · 1×
@types/node24.13.1 · 1×
@types/pg8.20.0 · 1×

Datastores touched

(mysql)Database · 1 repos
(mongodb)Database · 1 repos
dbnameDatabase · 1 repos
keyv_testDatabase · 1 repos
keyv_testDatabase · 1 repos
dbDatabase · 1 repos
dbnameDatabase · 1 repos
dbDatabase · 1 repos

For agents

$ claude mcp add keyv \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact