
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
memory-cache
Advanced tools
A simple in-memory cache for node.js
npm install memory-cache --save
var cache = require('memory-cache');
// now just use the cache
cache.put('foo', 'bar');
console.log(cache.get('foo'));
// that wasn't too interesting, here's the good part
cache.put('houdini', 'disappear', 100, function(key, value) {
console.log(key + ' did ' + value);
}); // Time in ms
console.log('Houdini will now ' + cache.get('houdini'));
setTimeout(function() {
console.log('Houdini is ' + cache.get('houdini'));
}, 200);
// create new cache instance
var newCache = new cache.Cache();
newCache.put('foo', 'newbaz');
setTimeout(function() {
console.log('foo in old cache is ' + cache.get('foo'));
console.log('foo in new cache is ' + newCache.get('foo'));
}, 200);
which should print
bar
Houdini will now disappear
houdini did disappear
Houdini is null
foo in old cache is baz
foo in new cache is newbaz
setTimeout)function(key, value) {})null== size() unless a setTimeout removal went wrongexport into the cacheimport will remain in the cacheskipDuplicates is trueoptions:
skipDuplicates: If true, any duplicate keys will be ignored when importing them. Defaults to false.require('cache') would return the default instance of Cacherequire('cache').Cache is the actual classnode-cache is another in-memory caching solution for Node.js. It offers similar functionality to memory-cache, including setting, getting, and deleting cache values, as well as setting expiration times. One key difference is that node-cache provides additional features such as event listeners for cache hits and misses, and the ability to store multiple values at once.
lru-cache is a caching solution that implements a Least Recently Used (LRU) algorithm. This means that it automatically removes the least recently accessed items when the cache reaches its maximum size. This can be useful for managing memory usage more effectively compared to memory-cache, which does not have built-in eviction policies.
cache-manager is a more advanced caching solution that supports multiple storage backends, including in-memory, Redis, and others. It provides a consistent API for interacting with different types of caches and offers features such as hierarchical caching and custom cache stores. This makes it more versatile than memory-cache, which is limited to in-memory storage.
FAQs
A simple in-memory cache. put(), get() and del()
The npm package memory-cache receives a total of 505,828 weekly downloads. As such, memory-cache popularity was classified as popular.
We found that memory-cache demonstrated a not healthy version release cadence and project activity because the last version was released 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
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.