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

minicaches

v0.1.1

Published

A fast, lightweight, async-compatible in-memory cache with TTL support and automatic cleanup - Rust-powered native addon

Readme

🚀 MiniCaches - High-Performance Node.js Cache

npm version License: MIT

A blazing-fast, lightweight, async-compatible in-memory cache for Node.js with TTL support and automatic cleanup. Powered by Rust for maximum performance.

✨ Features

  • 🔥 Native Performance: Rust-powered for maximum speed
  • ⚡ Async/Await Ready: Built for modern Node.js applications
  • ⏰ TTL Support: Automatic expiration with background cleanup
  • 🔒 Thread-Safe: Concurrent access support
  • 💾 Memory Efficient: Minimal overhead per cache entry
  • 🛠 Easy to Use: Simple, intuitive JavaScript API
  • 📊 High Throughput: Millions of operations per second
  • 🌍 Cross-Platform: Works on Windows, macOS, and Linux

📦 Installation

npm install minicaches
# or
yarn add minicaches

🚀 Quick Start

JavaScript (CommonJS)

const { JsCache } = require('minicaches');

async function example() {
  // Create cache
  const cache = new JsCache();
  
  // Set values with optional TTL
  await cache.set('user:123', 'John Doe');
  await cache.set('session:abc', 'temp_data', 300000); // 5 minutes TTL
  
  // Get values
  const user = await cache.get('user:123');
  console.log(user); // 'John Doe'
  
  // Check if key exists
  const hasSession = await cache.has('session:abc');
  console.log(hasSession); // true
  
  // Get cache size
  const size = await cache.size();
  console.log(`Cache has ${size} entries`);
}

example();

TypeScript

import { JsCache } from 'minicaches';

const cache = new JsCache();

// Type-safe operations
await cache.set('user:1', 'Alice', 300000);
const user: string | null = await cache.get('user:1');

if (user) {
  console.log(`Found user: ${user}`);
}

📖 API Reference

Constructor

const cache = new JsCache();

Methods

set(key: string, value: string, ttlMs?: number): Promise<void>

Set a key-value pair with optional TTL in milliseconds.

await cache.set('key', 'value');           // No expiration
await cache.set('key', 'value', 60000);    // Expires in 1 minute

get(key: string): Promise<string | null>

Get a value by key. Returns null if not found or expired.

const value = await cache.get('key');

remove(key: string): Promise<void>

Remove a key from the cache.

await cache.remove('key');

clear(): Promise<void>

Remove all entries from the cache.

await cache.clear();

size(): Promise<number>

Get the number of entries in the cache.

const count = await cache.size();

getInfo(): string

Get information about the cache implementation.

const { getInfo } = require('minicaches');
console.log(getInfo()); // Version and backend info

🚀 Performance

MiniCaches delivers exceptional performance thanks to its Rust backend:

  • Read Operations: ~13.7M operations/second
  • Write Operations: ~9.6M operations/second
  • Concurrent Access: ~1.7M operations/second
  • Memory Overhead: ~162 bytes per entry

🛠 Use Cases

Perfect for:

  • API Response Caching: Cache expensive API calls
  • Session Storage: Fast session data retrieval
  • Computed Results: Cache heavy computations
  • Rate Limiting: Track request counts with TTL
  • Configuration Cache: Store frequently accessed config
  • Temporary Data: Auto-expiring temporary storage

🌍 Platform Support

Pre-built binaries available for:

  • macOS: Intel (x64) and Apple Silicon (ARM64)
  • Windows: x64, x86, ARM64
  • Linux: x64, ARM64, ARM (glibc and musl)
  • FreeBSD: x64

🔧 Examples

Session Management

const { JsCache } = require('minicaches');
const cache = new JsCache();

// Store session with 30-minute expiration
await cache.set('session:' + userId, sessionData, 30 * 60 * 1000);

// Check if session is valid
const session = await cache.get('session:' + userId);
if (session) {
  // Session is valid
  console.log('User is authenticated');
} else {
  // Session expired or doesn't exist
  console.log('Please log in');
}

API Response Caching

async function getCachedApiData(endpoint) {
  const cacheKey = `api:${endpoint}`;
  
  // Try cache first
  let data = await cache.get(cacheKey);
  if (data) {
    return JSON.parse(data);
  }
  
  // Fetch from API
  const response = await fetch(endpoint);
  data = await response.json();
  
  // Cache for 5 minutes
  await cache.set(cacheKey, JSON.stringify(data), 5 * 60 * 1000);
  
  return data;
}

Rate Limiting

async function checkRateLimit(userId, maxRequests = 100) {
  const key = `rate_limit:${userId}`;
  const current = await cache.get(key);
  
  if (current === null) {
    // First request in this window
    await cache.set(key, '1', 60 * 1000); // 1 minute window
    return true;
  }
  
  const count = parseInt(current);
  if (count >= maxRequests) {
    return false; // Rate limit exceeded
  }
  
  // Increment counter
  await cache.set(key, (count + 1).toString(), 60 * 1000);
  return true;
}

🤝 Contributing

Contributions welcome! Please check the GitHub repository.

📄 License

MIT License - see LICENSE file for details.

🔗 Links


Built with ❤️ using Rust and N-API