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 🙏

© 2025 – Pkg Stats / Ryan Hefner

keyv-nedb-store

v0.0.10

Published

A Keyv store implementation using NeDB as the backend storage

Downloads

5,692

Readme

keyv-nedb-store

A Keyv store implementation using NeDB (@seald-io/nedb) as the backend storage.

Features

  • File-based storage - Persistent key-value storage using NeDB's file system backend
  • YAML-friendly - NeDB files are human-readable and linter-friendly
  • Namespace support - Organize your data with namespaces
  • TTL support - Set time-to-live for automatic key expiration
  • Custom serialization - Optional JSON serialization for complex data types
  • TypeScript - Fully typed with TypeScript support

Installation

bun install keyv-nedb-store @seald-io/nedb

Or with npm:

npm install keyv-nedb-store @seald-io/nedb

Usage

Basic Example

import Keyv from "keyv";
import { KeyvNedbStore } from "keyv-nedb-store";

// Create a store with file-based persistence
const store = new KeyvNedbStore(".cache/database.nedb.yaml");

const keyv = new Keyv({ store });

// Set a value
await keyv.set("foo", "bar");

// Get a value
const value = await keyv.get("foo"); // "bar"

// Delete a value
await keyv.delete("foo");

// Clear all values
await keyv.clear();

With Namespace

const store = new KeyvNedbStore({
  filename: "database.nedb.yaml",
  namespace: "myapp",
  autoload: true
});

const keyv = new Keyv({ store });

await keyv.set("user:1", { name: "Alice" });
// Stored with key: "myapp:user:1"

With TTL (Time-To-Live)

const keyv = new Keyv({ store });

// Set a value that expires in 1 second
await keyv.set("temp", "value", 1000);

// Wait for expiration
await new Promise(resolve => setTimeout(resolve, 1100));

const value = await keyv.get("temp"); // undefined

With Custom Serialization

const store = new KeyvNedbStore({
  filename: "database.nedb.yaml",
  serializer: {
    stringify: JSON.stringify,
    parse: JSON.parse
  },
  autoload: true
});

const keyv = new Keyv({ store });

// Store complex objects
await keyv.set("user", { id: 1, name: "Alice", roles: ["admin", "user"] });

API

new KeyvNedbStore(options)

Creates a new NeDB store instance.

Options

All NeDB DataStoreOptions are supported, plus:

  • namespace (string, optional) - Prefix for all keys
  • serializer (object, optional) - Custom serialization for values
    • stringify (function) - Serialize value to string
    • parse (function) - Deserialize string to value

Common NeDB options:

  • filename (string) - Path to the database file
  • autoload (boolean) - Automatically load the database
  • inMemoryOnly (boolean) - Use in-memory only (no persistence)

Store Methods

Implements the Keyv Store Adapter interface:

  • get(key) - Get a value by key
  • set(key, value, ttl?) - Set a value with optional TTL in milliseconds
  • delete(key) - Delete a value by key
  • clear() - Clear all values (respects namespace)

Why NeDB?

NeDB is a lightweight, embedded database that:

  • Requires no separate database server
  • Stores data in human-readable files
  • Works great with YAML linters
  • Provides a MongoDB-like API
  • Supports indexing and complex queries

Perfect for:

  • Configuration storage
  • Cache storage
  • Small to medium datasets
  • Serverless environments
  • Development and testing

Development

Built with Bun:

# Install dependencies
bun install

# Format code
bun run fmt

# Build
bun run build

License

MIT

Related

  • Keyv - Simple key-value storage with support for multiple backends
  • NeDB - Embedded persistent database for Node.js