
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
## Overview Neocache is a blazingly fast, minimal cache library, up to 31% faster than other popular cache libraries.
Neocache is a blazingly fast, minimal cache library, up to 31% faster than other popular cache libraries.
https://www.npmjs.com/package/neocache
See benchmarking for details.
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;
});
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
});
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
});
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:
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.
@jeanno - main author
@vxern - implemented generics
@Gobd - provided test cases and feedback
FAQs
## Overview Neocache is a blazingly fast, minimal cache library, up to 31% faster than other popular cache libraries.
We found that neocache demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.