npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

keyv-duckdb

v0.1.13

Published

DuckDB storage adapter for Keyv with AES-256-GCM encryption support

Readme

keyv-duckdb

A local DuckDB storage adapter for Keyv, with optional database encryption.

npm License: MIT

Use it when you want Keyv's cache API backed by a local DuckDB file. The adapter supports batch methods and key iteration through Keyv's store interface.

Install

npm install keyv keyv-duckdb

Install both packages: keyv-duckdb provides the storage adapter, while keyv provides the public cache API.

Node.js 16 or newer is required. This package declares a peer dependency on Keyv 5.5.5 or newer.

Quick Start

import Keyv from 'keyv';
import { KeyvDuckDB } from 'keyv-duckdb';

// Create a Keyv instance with DuckDB storage
const keyv = new Keyv({
  store: new KeyvDuckDB('./my-database.duckdb')
});

// Use Keyv's standard API
await keyv.set('hello', 'world');
const value = await keyv.get('hello'); // 'world'

Keyv handles serialization, TTL, and namespacing. Use KeyvDuckDB as the store passed to Keyv, rather than as the public cache API.

Encryption

import Keyv from 'keyv';
import { KeyvDuckDB } from 'keyv-duckdb';

const keyv = new Keyv({
  store: new KeyvDuckDB('./secure.duckdb', {
    encryptionKey: process.env.KEYV_DUCKDB_KEY
  })
});

// Set KEYV_DUCKDB_KEY before starting this program.
await keyv.set('key', { complex: 'object' });
const value = await keyv.get('key');

Options

interface KeyvDuckDBOptions {
  /** Path to DuckDB database file. Default: ~/.keyv-duckdb/store.duckdb */
  path?: string;
  
  /** Table name for key-value storage. Default: 'keyv' */
  table?: string;
  
  /** Encryption key passed to DuckDB */
  encryptionKey?: string;
  
  /** Maximum key size in characters */
  keySize?: number;

  /** Keyv dialect identifier and database URL */
  dialect?: string;
  url?: string;
}

When an encryptionKey is provided, the adapter opens the database with DuckDB's native database-level encryption. The key is required for every subsequent connection. Keep it outside the database, and do not expect encryption to have zero performance cost. If the key is lost, the encrypted data cannot be recovered.

Advanced Usage

Custom Table and Path

const store = new KeyvDuckDB({
  path: './custom/path/data.duckdb',
  table: 'cache',
  keySize: 500
});

Namespace Support

const store = new KeyvDuckDB('./my-database.duckdb');
const users = new Keyv({ store, namespace: 'users' });
const posts = new Keyv({ store, namespace: 'posts' });

await users.set('123', { name: 'Alice' });
await posts.set('456', { title: 'Hello' });

// Namespaces are isolated
await users.clear(); // Only clears users namespace

Troubleshooting

Database locked errors: Ensure only one process accesses the database file at a time.

Encryption errors: Verify that the same encryption key is used for every connection.

General Keyv issues: See the Keyv documentation for help with Keyv-specific features and patterns.

Resources

Contributing

See CONTRIBUTING.md for development guidelines.

License

MIT © Kevin Malakoff