Registry / storage / ocbesbn-cache

ocbesbn-cache

JSON →
library1.0.9jsnpmunverified

General cache abstraction layer providing a unified front-end for cache access independent of the underlying technology. Version 1.0.9 ships with three built-in providers: dummy, memory, and Redis. The package requires additional infrastructure (Consul and Redis) when using the Redis backend. It uses a Promise-based API and is designed for Node.js environments. Minimal setup involves creating a Cache instance with optional configuration for driver, key prefix, default expiration, and plugin directory. The library is part of the OpusCapita ecosystem and has seen limited updates since its initial release.

npm install ocbesbn-cache
INSTALL
IMPORT
SIG · OCBESBN-CACHE
O
ocbesbn-cache
storagejavascriptv1.0.9
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.

Cache
const Cache = require('ocbesbn-cache');
CommonJS require is the default and only supported import style. No ES module support.
Cache (with options)
const cache = new Cache({ driver: 'memory', keyPrefix: 'myapp:', defaultExpire: 300 });
const cache = new Cache('memory');
The constructor accepts an options object, not a string. Passing a string will cause unexpected behavior.
instance methods
cache.put('key', 'value').then(() => cache.get('key')).then(console.log);
cache.put('key', 'value', function(err, result) { ... });
All cache operations return Promises, not callbacks. Use .then() or async/await.

Demonstrates basic Cache usage with memory driver: put, get, remove operations.

const Cache = require('ocbesbn-cache'); async function main() { const cache = new Cache({ driver: 'memory', defaultExpire: 600 }); await cache.put('greeting', 'Hello, world!'); const value = await cache.get('greeting'); console.log(value); // 'Hello, world!' await cache.remove('greeting'); const missing = await cache.get('greeting'); console.log(missing); // null } main().catch(console.error);
Debug
Known issues
gotchaRedis backend requires Consul for endpoint configuration and a running Redis server.
fix
Ensure Consul and Redis are accessible, or use memory/dummy driver.
affects: >=1.0
gotchaThe constructor expects an options object; passing a string will be ignored or cause errors.
fix
Use new Cache({ driver: 'memory' }) instead of new Cache('memory').
affects: >=1.0
gotchaAll methods return Promises, not callbacks. Callback patterns will not work.
fix
Use .then() or async/await instead of callbacks.
affects: >=1.0
deprecatedThe `pluginDirectory` configuration option may be deprecated in future versions.
fix
Avoid relying on custom plugin directory; use built-in drivers.
affects: >1.0.9
Errors
Common errors & fixes
TypeError: Cache is not a constructor
Using ES6 import syntax (import Cache from 'ocbesbn-cache') which is not supported.
fix
Use CommonJS require: const Cache = require('ocbesbn-cache');
Error: Redis connection failed: connect ECONNREFUSED
Redis server not running or Consul configuration missing.
fix
Start Redis server and ensure Consul provides correct endpoint.
TypeError: cache.put(...).then is not a function
Methods return a value (maybe undefined) instead of a Promise, likely due to incorrect driver or cache instance.
fix
Verify that Cache was instantiated correctly with the new operator.
Upgrade
Version history
1.0.9latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
22
Amazon
1
Resources
ocbesbn-cache — npm install ocbesbn-cache · libregistry