Registry / storage / cache-conf

cache-conf

JSON →
library0.6.0jsnpmunverified

Simple cache config handling for your app or module. Version 0.6.0 is the latest stable release (last updated in 2018). It extends the `conf` package to add caching capabilities: supports maxAge (TTL) per key, version-based invalidation, and expiration checks. Use when you need persistent configuration with automatic cache expiry. Not actively maintained; consider alternatives like `conf` with manual caching or updated packages.

npm install cache-conf
INSTALL
IMPORT
SIG · CACHE-CONF
C
cache-conf
storagejavascriptv0.6.0
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.

CacheConf
✓ const CacheConf = require('cache-conf')
✗ import CacheConf from 'cache-conf'
CommonJS only; no default ESM export. For TypeScript use `import CacheConf = require('cache-conf')` or use the `esModuleInterop` flag with `import CacheConf from 'cache-conf'`.
CacheConf class
✓ const config = new CacheConf()
Instantiated without `new` throws TypeError: Class constructor CacheConf cannot be invoked without 'new'.
Instance methods: get, set, isExpired
✓ config.get('key', { ignoreMaxAge: true }); config.set('key', val, { maxAge: 1000 }); config.isExpired('key')
✗ CacheConf.get('key')
Methods are instance methods, not static. `set` with object sets multiple keys; options are per-key.
options for set/get
✓ config.set({a:1, b:2}, {maxAge: 10000})
✗ config.set({a:1, b:2}, {version: '1'})
When setting an object, options apply to all keys. Version option is for single key. Use nested set calls for per-key options.

Shows basic usage: setting a key with maxAge, retrieving before and after expiry, using ignoreMaxAge, and checking expiration with isExpired.

const CacheConf = require('cache-conf'); const config = new CacheConf(); // Set with 5 second expiry config.set('unicorn', '🦄', { maxAge: 5000 }); console.log(config.get('unicorn')); //=> '🦄' // Wait 5 seconds (use delay in async function) setTimeout(() => { console.log(config.get('unicorn')); //=> undefined (expired) }, 5000); // Force get even if expired console.log(config.get('unicorn', { ignoreMaxAge: true })); //=> '🦄' // Check expiry without retrieving console.log(config.isExpired('unicorn')); //=> false (before timeout) or true (after)
Debug
Known issues
gotchaCommonJS-only module; no ES module export. Using `import CacheConf from 'cache-conf'` fails.
fix
Use `const CacheConf = require('cache-conf');` or for TypeScript, use `import CacheConf = require('cache-conf');`.
affects: >=0.6.0
deprecatedPackage is in maintenance mode; last release in 2018. No updates for security or Node.js versions.
fix
Consider migrating to `conf` and implementing your own caching, or use a maintained alternative.
affects: >=0.6.0
gotchaWhen setting multiple keys via object, options like `maxAge` apply to all keys at once, not individually.
fix
Set keys individually with separate options if different maxAge per key is needed.
affects: >=0.6.0
gotcha`set` with an object doesn't allow per-key version; version option is only for single key sets.
fix
Use individual `set` calls for keys that need version differentiation.
affects: >=0.6.0
Errors
Common errors & fixes
TypeError: Class constructor CacheConf cannot be invoked without 'new'
Used `CacheConf()` without `new`
fix
Use `new CacheConf()` or `new (require('cache-conf'))()`
TypeError: CacheConf is not a constructor
Tried to `import CacheConf from 'cache-conf'` in ESM context
fix
Use CommonJS require, or configure bundler to handle CommonJS. For TypeScript: `import CacheConf = require('cache-conf')`
SyntaxError: Unexpected token 'export'
Attempting to import as ES module (package has only CommonJS)
fix
Switch to CommonJS `require` or use a transpiler/polyfill.
Upgrade
Version history
0.6.0latest on npm
Audit
Dependencies
confrequiredextends Conf for non-cached config handling; mandatory dependency
delayoptionalused in example for async waits; not a runtime dependency
Agent activity
35 hits · last 30 days
node
32
Resources
cache-conf — npm install cache-conf · libregistry