{"id":45388,"library":"mem-cache","title":"mem-cache","description":"Simple in-memory key/value cache for Node.js with automatic timeout-based expiration. Version 0.0.5 is the current stable release. The library provides basic cache operations (set, get, remove, clean) and emits events on entry expiration. It differs from more complex caching solutions (e.g., node-cache, lru-cache) by its minimal API and lack of advanced features like LRU eviction or TTL per entry. It is lightweight but offers configurable global timeout, optional timeout renewal on access, and the ability to disable timeout entirely.","status":"active","version":"0.0.5","language":"javascript","source_language":"en","source_url":"git://github.com/silviom/node-mem-cache","tags":["javascript","cache"],"install":[{"cmd":"npm install mem-cache","lang":"bash","label":"npm"},{"cmd":"yarn add mem-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add mem-cache","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS only; ESM import will fail.","wrong":"import Cache from 'mem-cache';","symbol":"Cache","correct":"var Cache = require('mem-cache');"},{"note":"Constructor with empty object is fine but unnecessary; omit if using defaults.","wrong":"var cache = new Cache({});","symbol":"Cache","correct":"var cache = new Cache();"},{"note":"Timeout is optional; calling with 3 args is valid only if using custom timeout.","wrong":"cache.set('key', value, 1000);","symbol":"set","correct":"cache.set('key', value);"}],"quickstart":{"code":"var Cache = require('mem-cache');\nvar cache = new Cache({ timeout: 5000 });\ncache.set('foo', 'bar');\nconsole.log(cache.get('foo')); // 'bar'\nsetTimeout(function() {\n  console.log(cache.get('foo')); // null after 5 seconds\n}, 6000);","lang":"javascript","description":"Shows basic usage: create cache with 5-second timeout, set and get value, then confirm auto-expiration."},"warnings":[{"fix":"Set timeoutDisabled: false and ensure appropriate timeout values, or manually clean cache.","message":"Memory leak risk: cache entries with no timeout (timeoutDisabled: true) never expire and can accumulate.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider using node-cache or lru-cache which are actively maintained.","message":"No updates since 2013; package may have unpatched vulnerabilities.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use 'keys' only for debugging; rely on 'length' after ensuring no expired items remain.","message":"The 'keys' property includes expired but not yet cleaned entries; length may not reflect active entries.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.0.5':19 'abil':86 'access':83 'advanc':62 'api':58 'automat':13 'base':16 'basic':28 'cach':3,9,29,46,51,54,92 'clean':34 'complex':45 'configur':76 'current':22 'differ':42 'disabl':88 'e.g':48 'emit':36 'entir':90 'entri':39,70 'event':37 'evict':66 'expir':17,40 'featur':63 'get':32 'global':77 'in-memori':5 'javascript':91 'key/value':8 'lack':60 'librari':26 'lightweight':73 'like':64 'lru':53,65 'lru-cach':52 'mem':2 'mem-cach':1 'memori':7 'minim':57 'node':50 'node-cach':49 'node.js':11 'offer':75 'oper':30 'option':79 'per':69 'provid':27 'releas':24 'remov':33 'renew':81 'set':31 'simpl':4 'solut':47 'stabl':23 'timeout':15,78,80,89 'timeout-bas':14 'ttl':68 'version':18","created_at":"2026-06-07T12:54:46.392353+00:00","updated_at":"2026-06-07T12:54:46.392353+00:00","problems":[{"fix":"Run 'npm install mem-cache' and verify package.json.","cause":"Package not installed or misspelled.","error":"Cannot find module 'mem-cache'"},{"fix":"Use 'require' and 'new Cache()' as shown in docs.","cause":"Using import statement incorrectly or cache is not instantiated via new.","error":"TypeError: cache.get is not a function"},{"fix":"Use 'var cache = new Cache();'","cause":"Calling cache() instead of new Cache().","error":"undefined is not a function"}],"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/silviom/node-mem-cache","github":"git://github.com/silviom/node-mem-cache","docs":null,"changelog":null,"pypi":null,"npm":"mem-cache","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}}