{"id":45634,"library":"nx-cache","title":"Nx Cache","description":"nx-cache is a minimal in-memory cache SDK for Node.js (v1.0.2, stable) that requires zero configuration and supports TTL, scoped keys, and user-defined metadata. Unlike full-featured caching solutions (node-cache, lru-cache), nx-cache emphasizes simplicity: no setup, no config, and a focused API for write, read, search, and reset operations. It ships TypeScript types and is per-process memory only, with planned future backends (Redis, disk).","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/nx-intelligence/nx-cache","tags":["javascript","cache","memory","ttl","typescript"],"install":[{"cmd":"npm install nx-cache","lang":"bash","label":"npm"},{"cmd":"yarn add nx-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add nx-cache","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Requires ESM import; CommonJS require returns a different shape.","wrong":"const createNxCache = require('nx-cache')","symbol":"createNxCache","correct":"import { createNxCache } from 'nx-cache'"},{"note":"NxCache is a type, not a value. Use type import or import type.","wrong":"import { NxCache } from 'nx-cache'","symbol":"NxCache","correct":"import type { NxCache } from 'nx-cache'"},{"note":"Dynamic import with CommonJS require fails; use async import.","wrong":"const { createNxCache } = require('nx-cache')","symbol":"createNxCache","correct":"const { createNxCache } = await import('nx-cache')"}],"quickstart":{"code":"// install: npm i nx-cache@1.0.2\nimport { createNxCache } from 'nx-cache';\n\nconst cache = createNxCache();\n\ncache.write('user', { name: 'Alice' }, {\n  scope: { tenant: 'acme' },\n});\n\nconst data = cache.read('user', { tenant: 'acme' });\nif (data.found) {\n  console.log('User:', data.value);\n} else {\n  console.log('Not found');\n}\n\ncache.resetKey('user', { tenant: 'acme' });\n","lang":"typescript","description":"Creates a cache instance, writes a scoped entry, reads it back, and then resets the key."},"warnings":[{"fix":"Always pass a scope object (or null) matching the write call.","message":"Scope is required for read/write unless you explicitly pass null/undefined. Without scope, the key is not matched.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"To set custom TTL, look for future API additions; in v1, manage TTL manually or use another library.","message":"Default TTL is 1 year; entries never expire unless manually reset or overwritten.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use ESM imports (import { createNxCache } from 'nx-cache') instead of require().","message":"TypeScript types ship with the package but are not exported in CJS fashion; CommonJS require returns an object with a different shape.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Apply additional filtering on the returned array if needed.","message":"search() returns an array of results; it does not support filtering by metadata content, only by key and scope.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use with caution; consider resetKey() for targeted removal.","message":"resetAll() clears the entire cache, affecting all keys and scopes. No confirmation.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'api':56 'backend':78 'cach':2,5,12,36,40,43,46,82 'config':52 'configur':21 'defin':30 'disk':80 'emphas':47 'featur':35 'focus':55 'full':34 'full-featur':33 'futur':77 'in-memori':9 'javascript':81 'key':26 'lru':42 'lru-cach':41 'memori':11,73,83 'metadata':31 'minim':8 'node':39 'node-cach':38 'node.js':15 'nx':1,4,45 'nx-cach':3,44 'oper':63 'per':71 'per-process':70 'plan':76 'process':72 'read':59 'redi':79 'requir':19 'reset':62 'scope':25 'sdk':13 'search':60 'setup':50 'ship':65 'simplic':48 'solut':37 'stabl':17 'support':23 'ttl':24,84 'type':67 'typescript':66,85 'unlik':32 'user':29 'user-defin':28 'v1.0.2':16 'write':58 'zero':20","created_at":"2026-06-07T12:55:58.367943+00:00","updated_at":"2026-06-07T12:55:58.367943+00:00","problems":[{"fix":"Change `const { createNxCache } = require('nx-cache')` to `import { createNxCache } from 'nx-cache'`","cause":"Using CommonJS require instead of ESM import","error":"TypeError: createNxCache is not a function"},{"fix":"Ensure you use `import { createNxCache } from 'nx-cache'` and have TypeScript's esModuleInterop enabled if needed.","cause":"Wrong import or TypeScript not recognizing the type","error":"Property 'found' does not exist on type '...'"},{"fix":"Verify that the scope object passed to read() exactly matches the one used in write(), including key order is irrelevant but same properties.","cause":"Scope mismatch between write and read","error":"nx-cache: key 'user' not found (even after writing)"},{"fix":"Run `npm install nx-cache` and check that the import path is exactly `'nx-cache'`.","cause":"Package not installed or incorrect import path","error":"Module not found: Can't resolve 'nx-cache'"},{"fix":"Pass null explicitly if no scope: `cache.write('key', value, { scope: null })`","cause":"Passing an empty object as scope when WriteOptions expects NxScope | null","error":"Type '{}' is not assignable to type 'NxScope | null'"}],"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/nx-intelligence/nx-cache#readme","github":"https://github.com/nx-intelligence/nx-cache","docs":null,"changelog":null,"pypi":null,"npm":"nx-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}}