{"id":45561,"library":"node-cache-engine","title":"node-cache-engine","description":"High-performance caching library for Node.js and browser environments supporting LRU and LFU eviction policies with O(1) complexity for all operations. Version 2.0.3 requires Node >=18.18.2. Ships TypeScript definitions. Differentiates from other caches by supporting both LRU and LFU engines, custom hash tables via symbols, and a unified API with clearAll and toArray methods for LRU. Offers configurable maximum size. Actively maintained with regular releases.","status":"active","version":"2.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/benhurdavies/node-cache-engine","tags":["javascript","node","cache","high","performance","cache replacement","javascript cache","LRU cache","typescript"],"install":[{"cmd":"npm install node-cache-engine","lang":"bash","label":"npm"},{"cmd":"yarn add node-cache-engine","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-cache-engine","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Always use named import. CommonJS require works but default is ESM.","wrong":"const createCache = require('node-cache-engine').createCache","symbol":"createCache","correct":"import { createCache } from 'node-cache-engine'"},{"note":"Set engine via option string, not imported class.","wrong":"import { LRU } from 'node-cache-engine'","symbol":"LRU engine","correct":"const cache = createCache({ engine: 'LRU' })"},{"note":"Engine key is uppercase: 'LRU' or 'LFU'.","wrong":"const cache = createCache({ engine: 'lfu' })","symbol":"LFU engine","correct":"const cache = createCache({ engine: 'LFU' })"}],"quickstart":{"code":"import { createCache } from 'node-cache-engine';\n\nconst cache = createCache({ size: 100, engine: 'LRU' });\ncache.add('user:123', { name: 'Alice' });\nconst user = cache.get('user:123');\nif (cache.has('user:123')) {\n  cache.remove('user:123');\n}\nconsole.log(cache.size()); // 0\ncache.add('a', 1);\nconsole.log(cache.toArray()); // [['a', 1]]","lang":"typescript","description":"Shows creating a cache instance, adding, getting, checking, removing, and iterating items."},"warnings":[{"fix":"Upgrade Node.js to >=18.18.2 or pin version to 1.x.","message":"Node.js version requirement was raised to >=18.18.2 in v2.0.0.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Always provide an explicit size option to avoid unbounded growth.","message":"The default maximum size is Number.MAX_SAFE_INTEGER, which may cause memory issues if not limited.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use default hash table unless you have extreme performance needs >5M entries.","message":"Custom hash table must implement symbols from package; internal structure may change in minor versions.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Ensure engine string is uppercase: 'LRU' or 'LFU'.","message":"Engine option is case-sensitive: 'LRU' or 'LFU'. Lowercase will treat as invalid and may default silently.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use LRU if you need those methods, or implement your own iteration for LFU.","message":"clearAll() and toArray() are only available on LRU engine, not LFU.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1':23 '18.18.2':32 '2.0.3':29 'activ':67 'api':55 'browser':13 'cach':3,8,39,74,77,80,82 'clearal':57 'complex':24 'configur':64 'custom':47 'definit':35 'differenti':36 'engin':4,46 'environ':14 'evict':19 'hash':48 'high':6,75 'high-perform':5 'javascript':72,79 'lfu':18,45 'librari':9 'lru':16,43,62,81 'maintain':68 'maximum':65 'method':60 'node':2,31,73 'node-cache-engin':1 'node.js':11 'o':22 'offer':63 'oper':27 'perform':7,76 'polici':20 'regular':70 'releas':71 'replac':78 'requir':30 'ship':33 'size':66 'support':15,41 'symbol':51 'tabl':49 'toarray':59 'typescript':34,83 'unifi':54 'version':28 'via':50","created_at":"2026-06-07T12:55:37.086787+00:00","updated_at":"2026-06-07T12:55:37.086787+00:00","problems":[{"fix":"import { createCache } from 'node-cache-engine'","cause":"Importing default instead of named export in ESM.","error":"TypeError: createCache is not a function"},{"fix":"Use engine: 'LRU' or engine: 'LFU' exactly.","cause":"Engine option passed as lowercase or misspelled.","error":"Error: engine must be LRU, LFU or custom"},{"fix":"Use LRU engine, or manually remove items by iterating keys.","cause":"Using LFU engine which does not have clearAll method.","error":"TypeError: cache.clearAll is not a function"},{"fix":"Use import statement or dynamic import().","cause":"Using CommonJS require with newer versions that are ESM-only.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/benhurdavies/node-cache-engine#readme","github":"https://github.com/benhurdavies/node-cache-engine","docs":null,"changelog":null,"pypi":null,"npm":"node-cache-engine","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}