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

neocache

v2.5.1

Published

## Overview Neocache is a blazingly fast, minimal cache library, up to 31% faster than other popular cache libraries.

Readme

Neocache

Overview

Neocache is a blazingly fast, minimal cache library, up to 31% faster than other popular cache libraries.

https://www.npmjs.com/package/neocache

Performance Highlights

  • Fastest overall SET operations - Up to 27% faster than lru-cache for large datasets
  • Great GET performance - Up to 7% faster than quick-lru for large datasets
  • Superior mixed operations - 12% faster than lru-cache and 14% faster than quick-lru
  • Excellent LRU eviction - 38% faster than lru-cache
  • Most consistent performance across all operation sizes from 100K to 10M items
  • Minimal memory footprint with excellent GC behavior

See benchmarking for details.

Features

  • Key-value based caching
  • Multiple eviction strategy
    • Custom expire time
    • LRU (Least Recently Used)
  • Configurable max size
  • Built-in benchmarking

Usage

Basic

import Neocache from 'neocache';
// For CommonJS
// const Neocache = require('neocache').default;

const cache = Neocache.instance;

const cacheId = 'customCacheId';

let cachedItem = cache.get(cacheId); // returns null, since the cache starts out as empty

cachedItem = cache.get(cacheId, async () => {
  // Put your data retrieval logic here.
  // This function is executed when cache doesn't exist or expired.
  const value = await fetchDataFromDatabase('itemId');
  return value;
});

// Later...
// Although the data retriving function is provided, it is not called because
// the cached value is used.
cachedItem = cache.get(cachedId, async () => {

  // Code is not executed here
  const value = await fetchDataFromDatabase('itemId');
  return value;
});

Custom cache

import Neocache from 'neocache';
// For CommonJS
// const Neocache = require('neocache').default;

// You can create multiple instance of Neocache instead of using the default.
const myCache = new Neocache();

const cacheId = 'customCacheId';
const cachedItem = myCache.get(cacheId, async () => {
  // ...
  return value;
});
import Neocache from 'neocache';

// You can also use custom configuration for expiration time and max size
const myCache = new Neocache({
  // Default time until items expire (in milliseconds)
  defaultExpireTimeMs: 3600000, // 1 hour
  
  // How often to check for and remove expired items (in milliseconds)
  purgeIntervalMs: 60000, // 1 minute
  
  // Maximum number of items to store in cache before LRU eviction
  maxSize: 1000
});

LRU Eviction

The cache uses a Least Recently Used (LRU) eviction strategy. When the cache reaches its maximum size, the least recently used items will be evicted to make room for new items.

To enable LRU eviction, specify the maxSize option when creating a cache instance:

const cache = new Neocache({
  maxSize: 1000 // Maximum 1000 items in cache
});

Benchmarking

Neocache comes with built-in benchmarking capabilities. To run benchmarks:

# Run comparative benchmarks against other popular cache libraries
npm run benchmark

# Run the original Neocache-only benchmarks
npm run benchmark:original

The comparative benchmark compares Neocache against other popular TypeScript/JavaScript cache libraries:

This will output performance metrics for various operations:

  1. SET operations: Measures performance of setting items in the cache
  2. GET operations: Measures performance of retrieving items from the cache
  3. LRU eviction: Measures performance when adding items to a full cache, triggering LRU eviction
  4. Mixed operations: Measures performance with a random mix of get and set operations
  5. Fixed size cache operations: Measures performance with a fixed size cache and repeated operations on the same keys

Sample benchmark results:

SET OPERATIONS
─────────────────────────────────────────────────────────
Library      | 100,000 items  | 1,000,000 items | 10,000,000 items
─────────────────────────────────────────────────────────
Neocache     | 2.73M ops/sec   | 4.90M ops/sec   | 4.82M ops/sec  👈 Fastest overall
lru-cache    | 2.63M ops/sec   | 3.69M ops/sec   | 3.74M ops/sec
quick-lru    | 3.79M ops/sec   | 4.47M ops/sec   | 4.50M ops/sec
tiny-lru     | 1.59M ops/sec   | 1.44M ops/sec   | 1.36M ops/sec


GET OPERATIONS
─────────────────────────────────────────────────────────
Library      | 100,000 items  | 1,000,000 items | 10,000,000 items
─────────────────────────────────────────────────────────
Neocache     | 5.94M ops/sec   | 7.68M ops/sec   | 7.27M ops/sec
lru-cache    | 4.96M ops/sec   | 8.29M ops/sec   | 8.60M ops/sec
quick-lru    | 5.45M ops/sec   | 6.92M ops/sec   | 7.49M ops/sec
tiny-lru     | 2.86M ops/sec   | 4.01M ops/sec   | 3.91M ops/sec


MIXED OPERATIONS (500,000 random get/set operations)
─────────────────────────────────────────────────────────
Library      | Performance
─────────────────────────────
Neocache     | 4.78M ops/sec  👈 Best mixed operations
lru-cache    | 4.24M ops/sec
quick-lru    | 4.11M ops/sec
tiny-lru     | 1.66M ops/sec


LRU EVICTION (adding 500,000 items to a cache of 10,000 items)
─────────────────────────────────────────────────────────
Library      | Performance
─────────────────────────────
Neocache     | 3.66M ops/sec  👈 Best LRU performance
lru-cache    | 3.10M ops/sec
quick-lru    | 3.51M ops/sec
tiny-lru     | 1.36M ops/sec

Note: Actual performance will vary based on your system. Run the benchmarks on your own machine for accurate results.

Contributors

@jeanno - main author

@vxern - implemented generics

@Gobd - provided test cases and feedback