Registry / storage / neocache

neocache

JSON →
library2.5.1jsnpmunverified

Neocache is a blazingly fast, minimal cache library for JavaScript/TypeScript, up to 31% faster than alternatives like lru-cache and quick-lru. Current stable version is 2.5.1. It supports key-value caching with LRU eviction and custom expiration times, and ships with TypeScript definitions. Key differentiators include superior performance in SET, GET, and mixed operations, minimal memory footprint, and built-in benchmarking tools. It is actively maintained.

npm install neocache
INSTALL
IMPORT
SIG · NEOCACHE
N
neocache
storagejavascriptv2.5.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Neocache
import Neocache from 'neocache'
const Neocache = require('neocache')
ESM default import. For CommonJS, use require('neocache').default.
default
const Neocache = require('neocache').default
const Neocache = require('neocache')
CommonJS requires .default access.
Neocache (type)
import type Neocache from 'neocache'
For type-only imports in TypeScript.

Creates a Neocache instance, gets a value with an async fallback, and shows custom configuration with LRU eviction.

import Neocache from 'neocache'; const cache = Neocache.instance; const cacheId = 'myKey'; // Get with fallback function let value = cache.get(cacheId, async () => { return await fetch('https://api.example.com/data').then(res => res.json()); }); // Later call uses cached value value = cache.get(cacheId, async () => { // Not executed if cached return {}; }); // Custom instance with options const customCache = new Neocache({ defaultExpireTimeMs: 3600000, purgeIntervalMs: 60000, maxSize: 1000 }); customCache.set('key', { data: 'value' });
Debug
Known issues
gotchaCommonJS require must use .default
fix
Use const Neocache = require('neocache').default
affects: >=2.0.0
gotchaNeocache instance is not a singleton by default; use Neocache.instance for shared instance
fix
Use Neocache.instance or create new Neocache() as needed
affects: *
Errors
Common errors & fixes
TypeError: Neocache is not a constructor
Using CommonJS require without .default
fix
const Neocache = require('neocache').default
Error: Cannot find module 'neocache'
Package not installed
fix
npm install neocache
Upgrade
Version history
2.5.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
32 hits · last 30 days
node
28
Amazon
1
OpenAI (training)
1
Resources
neocache — npm install neocache · libregistry