
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.
A hash-based LRU cache that evicts entries based on memory usage rather than time or item count.
A hash-based LRU cache for Node.js that evicts entries based on memory usage or item count. Designed for high performance and low memory overhead, with TypeScript support and memory monitoring utilities.
NPM:
npm install memoru
PNPM:
pnpm add memoru
import { Memoru } from 'memoru';
const lru = new Memoru({ max: 100 }); // max 100 items
lru.set('foo', 'bar');
console.log(lru.get('foo')); // 'bar'
Evict items automatically when process memory or V8 heap usage exceeds a threshold:
import { Memoru, ProcessMemoryStat } from 'memoru';
const lru = new Memoru({
max: 1000,
memoryStats: {
monitored: [
{ stat: ProcessMemoryStat.RSS, threshold: 100 * 1024 * 1024 }, // 100MB
],
interval: 1000, // check every second
},
});
All APIs are fully typed:
import { Memoru } from 'memoru';
const lru = new Memoru<string, number>({ max: 10 });
lru.set('a', 1);
const value: number | undefined = lru.get('a');
You can use the memory stats monitor directly:
import { MemoryStatsMonitor, ProcessMemoryStat } from 'memoru';
const monitor = new MemoryStatsMonitor({
monitored: [{ stat: ProcessMemoryStat.RSS, threshold: 200 * 1024 * 1024 }],
interval: 5000,
});
monitor.on('threshold', (stat) => {
console.log('Memory threshold exceeded for', stat);
});
You can enable garbage collection monitoring to prevent cache rotations during garbage collection:
import { HeapSpace, Memoru } from 'memoru';
const lru = new Memoru({
max: 1000,
respectGC: true, // Prevent rotations during GC
memoryStats: {
monitorGC: true, // Enable GC monitoring
gcCooldown: 500, // Wait 500ms after GC before allowing rotations
monitored: [
{ stat: HeapSpace.Old, threshold: 50 * 1024 * 1024 }, // 50MB
],
interval: 1000,
},
});
Note: GC monitoring uses Node.js PerformanceObserver API and works without additional flags.
## Demo
```typescript
import { Memoru } from 'memoru';
const lru = new Memoru({ max: 2 });
lru.set('a', 1);
lru.set('b', 2);
lru.set('c', 3); // 'a' is evicted
console.log(lru.get('a')); // undefined
console.log(lru.get('b')); // 2
console.log(lru.get('c')); // 3
FAQs
A hash-based LRU cache that evicts entries based on memory usage rather than time or item count.
The npm package memoru receives a total of 1 weekly downloads. As such, memoru popularity was classified as not popular.
We found that memoru 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.