Registry / storage / nx-cache

nx-cache

JSON →
library1.0.2jsnpmunverified

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

npm install nx-cache
INSTALL
IMPORT
SIG · NX-CACHE
N
nx-cache
storagejavascriptv1.0.2
harness data pending
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.

createNxCache
import { createNxCache } from 'nx-cache'
const createNxCache = require('nx-cache')
Requires ESM import; CommonJS require returns a different shape.
NxCache
import type { NxCache } from 'nx-cache'
import { NxCache } from 'nx-cache'
NxCache is a type, not a value. Use type import or import type.
createNxCache
const { createNxCache } = await import('nx-cache')
const { createNxCache } = require('nx-cache')
Dynamic import with CommonJS require fails; use async import.

Creates a cache instance, writes a scoped entry, reads it back, and then resets the key.

// install: npm i nx-cache@1.0.2 import { createNxCache } from 'nx-cache'; const cache = createNxCache(); cache.write('user', { name: 'Alice' }, { scope: { tenant: 'acme' }, }); const data = cache.read('user', { tenant: 'acme' }); if (data.found) { console.log('User:', data.value); } else { console.log('Not found'); } cache.resetKey('user', { tenant: 'acme' });
Debug
Known issues
gotchaScope is required for read/write unless you explicitly pass null/undefined. Without scope, the key is not matched.
fix
Always pass a scope object (or null) matching the write call.
affects: >=1.0.0
gotchaDefault TTL is 1 year; entries never expire unless manually reset or overwritten.
fix
To set custom TTL, look for future API additions; in v1, manage TTL manually or use another library.
affects: >=1.0.0
breakingTypeScript types ship with the package but are not exported in CJS fashion; CommonJS require returns an object with a different shape.
fix
Use ESM imports (import { createNxCache } from 'nx-cache') instead of require().
affects: >=1.0.0
gotchasearch() returns an array of results; it does not support filtering by metadata content, only by key and scope.
fix
Apply additional filtering on the returned array if needed.
affects: >=1.0.0
gotcharesetAll() clears the entire cache, affecting all keys and scopes. No confirmation.
fix
Use with caution; consider resetKey() for targeted removal.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: createNxCache is not a function
Using CommonJS require instead of ESM import
fix
Change `const { createNxCache } = require('nx-cache')` to `import { createNxCache } from 'nx-cache'`
Property 'found' does not exist on type '...'
Wrong import or TypeScript not recognizing the type
fix
Ensure you use `import { createNxCache } from 'nx-cache'` and have TypeScript's esModuleInterop enabled if needed.
nx-cache: key 'user' not found (even after writing)
Scope mismatch between write and read
fix
Verify that the scope object passed to read() exactly matches the one used in write(), including key order is irrelevant but same properties.
Module not found: Can't resolve 'nx-cache'
Package not installed or incorrect import path
fix
Run `npm install nx-cache` and check that the import path is exactly `'nx-cache'`.
Type '{}' is not assignable to type 'NxScope | null'
Passing an empty object as scope when WriteOptions expects NxScope | null
fix
Pass null explicitly if no scope: `cache.write('key', value, { scope: null })`
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
20
Amazon
1
OpenAI (training)
1
Resources
nx-cache — npm install nx-cache · libregistry