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

cache-minimal

v1.0.4

Published

A minimalist caching library with Redis and in-memory fallback

Downloads

27

Readme

cache-minimal

A lightweight caching library for Node.js with Redis and in-memory caching support. Designed for simplicity and flexibility.

🚀 Features

  • Supports both In-Memory and Redis caching
  • Custom TTL (Time-To-Live) for cached data
  • Easy integration with Node.js applications
  • Minimal dependencies & high performance

📦 Installation

Install via npm:

npm install cache-minimal

🔧 Usage

Basic In-Memory Caching

import { CacheManager } from "cache-minimal";

const cache = new CacheManager();

cache.set("name", "John Doe", 60); // Store with a 60-second TTL

const value = await cache.get("name");
console.log(value); // Output: John Doe

Using Redis as Cache Backend

Create a .env file in your project:

REDIS_HOST=your_redis_host
REDIS_PORT=your_redis_port
REDIS_USERNAME=your_redis_username
REDIS_PASSWORD=your_redis_password
REDIS_TTL=60
import { CacheManager } from "cache-minimal";

// Use parameters according to your use case. If you don't require username and password, you can skip those parameters.
const cache = new CacheManager({
  useRedis: true,
  host: REDIS_HOST,
  port: REDIS_PORT,
  username: REDIS_USERNAME, // Fixed typo here
  password: REDIS_PASSWORD,
  defaultTTL: REDIS_TTL,
});

await cache.set("user", { id: 1, name: "Alice" }, 120);

const user = await cache.get("user");
console.log(user); // Output: { id: 1, name: "Alice" }

Deleting a Cache Key

await cache.delete("name");

Clearing All Cache

await cache.clear();
console.log("All cache cleared!");

🌐 Environment Variables

If you are using Redis as the cache backend, you can configure the connection using a .env file. Create a .env file in your project root with the following variables:

REDIS_HOST=your_redis_host
REDIS_PORT=your_redis_port
REDIS_USERNAME=your_redis_username
REDIS_PASSWORD=your_redis_password
REDIS_TTL=60
  • REDIS_HOST: The hostname or IP address of your Redis server (default: localhost).
  • REDIS_PORT: The port number of your Redis server (default: 6379).
  • REDIS_USERNAME: (Optional) The username for Redis authentication.
  • REDIS_PASSWORD: (Optional) The password for Redis authentication.
  • REDIS_TTL: (Optional) Default time-to-live (TTL) for cached items in seconds (default: 60).

📖 API Reference

CacheManager

The main class for managing cache operations.

Constructor

new CacheManager(options?: CacheOptions)
  • options (optional): Configuration options for the cache.
    • useRedis (boolean): Whether to use Redis as the cache backend (default: false).
    • host (string): Redis host (default: localhost).
    • port (number): Redis port (default: 6379).
    • username (string): Redis username (optional).
    • password (string): Redis password (optional).
    • defaultTTL (number): Default TTL for cached items in seconds (default: 60).

Methods

  • set(key: string, value: any, ttl?: number): Promise<void>
    • Stores a value in the cache with an optional TTL.
  • get(key: string): Promise<any | null>
    • Retrieves a value from the cache by key.
  • delete(key: string): Promise<void>
    • Deletes a specific key from the cache.
  • clear(): Promise<void>
    • Clears all cached data.

📜 License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.