Registry / storage / lru-native2

lru-native2

JSON →
library1.2.6jsnpmunverified

An in-memory LRU cache for Node.js implemented in C++11 using std::unordered_map and std::list, offering high performance for large caches. Version 1.2.6 supports Node 14/16 on OSX and Linux. It is an alternative to node-lru-cache for very large hashes, avoiding V8 object overhead. Last updated in 2021, it is in maintenance mode with no recent releases.

storage
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.

Default export is the constructor. TypeScript types are included.

import LRUCache from 'lru-native2'

CommonJS users should use require without destructuring; the module exports a single constructor.

const LRUCache = require('lru-native2')

TypeScript types are bundled; the default import is the constructor class.

import LRUCache from 'lru-native2'

Shows instantiation with options, set/get, size, remove, clear, and stats.

import LRUCache from 'lru-native2'; const cache = new LRUCache({ maxElements: 1000, maxAge: 60000 }); cache.set('key1', 'value1'); cache.set('key2', 'value2'); console.log(cache.get('key1')); // 'value1' console.log(cache.size()); // 2 cache.remove('key2'); console.log(cache.get('key2')); // undefined cache.clear(); console.log(cache.size()); // 0 const stats = cache.stats(); console.log('Stats:', stats);
Debug
Known footguns
deprecatedPackage is deprecated. No updates since 2021. Use 'lru-cache' or other maintained alternatives.
breakingNative addon requires build tools. Installation may fail without node-gyp or on unsupported platforms.
gotchaKey must be a string; using non-string keys may cause unexpected behavior.
gotchamaxElements option default is 0, meaning no limit, not 0 items. Setting maxElements: 0 disables eviction.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
17 hits · last 30 days
gptbot
3
amazonbot
3
bytedance
3
ahrefsbot
1
Resources