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

redson

v1.0.3

Published

Simple, lightweight, file-based cache with memory tier using lowdb

Readme

Redson

Redson = Redis-like + JSON persistence
A tiny, zero-dependency, file-based key-value store with in-memory TTL caching for Node.js.

  • Persists data to a JSON file
  • In-memory cache with configurable TTL (time-to-live)
  • Simple Redis-inspired API (get, set, delete)
  • Automatic file creation & directory handling
  • Very lightweight (~150 LOC)

Perfect for small projects, CLI tools, bots, Electron apps, or any situation where you want Redis-like semantics without running a server.

Features

  • TTL-based expiration (per key)
  • Memory-first read pattern → fast repeated access
  • Atomic file writes with pretty-printed JSON
  • Async/await friendly
  • No external dependencies
  • Works in Node.js ≥ 18

Installation

npm install redson

Usage

import Redson from 'redson';

const db = new Redson({
  path: './data/store.json',     // default: ./data/cache.json
  cacheTime: 300,                // default: 60 seconds
});

await db.init();                 // must call once before using

// Basic operations
await db.set('user:123', { name: 'Alice', score: 420 });
const user = await db.get('user:123');
console.log(user);               // → { name: 'Alice', score: 420 }

await db.delete('user:123');

// TTL example (expires after cacheTime seconds)
await db.set('temp-token', 'xyz789', { ttl: 3600 }); // overrides global cacheTime

// Manual cache cleanup (optional)
db.prune();

You can also pass TTL per operation (overrides global setting):

await db.set('session:abc', { userId: 7 }, { ttl: 1800 }); // 30 minutes

API

class Redson {
  constructor(config?: { path?: string; cacheTime?: number });

  async init(): Promise<void>;
  // Must be called once before using the store

  async get(key: string): Promise<any | null>;
  async set(key: string, value: any, options?: { ttl?: number }): Promise<void>;
  async delete(key: string): Promise<void>;

  prune(): void;
  // Removes expired entries from memory cache (does not affect persisted data)
}

Configuration

new Redson({
  path: './storage/myapp-data.json',   // where to save the data
  cacheTime: 600                       // default TTL in seconds (10 min)
});

Important Notes

  • init() must be called before any get/set/delete operations
  • Values are serialized with JSON.stringify → only JSON-serializable data is supported
  • The file is not append-only — every set/delete rewrites the whole file
  • Not suitable for high write throughput (> few writes/second)
  • Not atomic across multiple instances (file locking not implemented)

When to use Redson

✅ Good for

  • Configuration storage
  • Rate limiting counters
  • Session data in small apps
  • Caching API responses
  • Development / prototyping
  • Low-traffic bots & CLIs

❌ Probably not suitable for

  • High concurrency / many writes
  • Large datasets (> few MB)
  • Production systems that need strong durability guarantees
  • Multi-process or clustered environments

License

MIT

Similar Projects

Enjoy simple persistence! "