Registry / database / data-point-cache

data-point-cache

JSON →
library4.1.1-alpha.0jsnpmunverified

DataPoint Cache Layer (v4.1.1-alpha.0) provides a simple, Redis-backed cache API with an in-memory short-TTL (default 2s) layer for optimal performance. It wraps ioredis to offer get/set operations with configurable TTL, local caching, and automatic expiration sweeping. Designed for Node 8+, this package is part of the DataPoint ecosystem from ViacomInc. Compared to raw ioredis, it adds transparent local caching and simplified key-value storage. Low release cadence; alpha status indicates potential instability.

npm install data-point-cache
INSTALL
IMPORT
SIG · DATA-POINT-CACHE
D
data-point-cache
databasejavascriptv4.1.1-alpha.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.

data-point-cache
import Cache from 'data-point-cache'
import { Cache } from 'data-point-cache'
Package uses default export. Named import will fail. ESM supported? Package uses require() in README, but modern bundlers may handle. Check if your setup supports ESM.
create
const { create } = require('data-point-cache')
import { create } from 'data-point-cache'
For CommonJS, destructure create. For ESM, use default import and call Cache.create().
Cache
const Cache = require('data-point-cache')
const cache = require('data-point-cache'); cache.create()
Cache is an object with create method. Use Cache.create() not cache.create().

Creates a cache instance, sets a value with TTL, retrieves it, and demonstrates missing key returns undefined.

const Cache = require('data-point-cache'); async function main() { const cache = await Cache.create({ // localTTL: 2000, // optional, ms // redis: { host: 'localhost', port: 6379 } // optional, passed to ioredis }); await cache.set('myKey', { foo: 'bar' }, '5m'); const value = await cache.get('myKey'); console.log(value); // { foo: 'bar' } const missing = await cache.get('nonexistent'); console.log(missing); // undefined } main().catch(console.error);
Debug
Known issues
deprecatedPackage is in alpha (v4.1.1-alpha.0). API may change before stable release.
fix
Pin to exact version and test upgrades. Do not use in production without careful evaluation.
affects: >=4.0.0-alpha
gotchaDefault export is an object with create method; not a class or function. CommonJS require returns { create, ... }.
fix
Use const Cache = require('data-point-cache'); then Cache.create() or destructure { create }.
affects: *
gotchacache.set returns undefined when not providing TTL? Default TTL is 20 minutes. Always check promise resolution.
fix
Ensure set returns a promise; await or .then() it. For no TTL, pass undefined or omit param.
affects: *
breakingNode >=8 required. Using older Node versions will fail.
fix
Upgrade Node to version 8 or higher.
affects: *
Errors
Common errors & fixes
TypeError: Cannot destructure property 'create' of 'require(...)' as it is undefined.
Incorrect import assuming default export is an object with create, but package exports default as object.
fix
Use const Cache = require('data-point-cache'); const cache = await Cache.create();
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server not running or connection options incorrect.
fix
Start Redis server or configure redis option with correct host/port. No redis option defaults to localhost:6379.
TypeError: cache.set is not a function
Called cache.set before cache instance resolved or used wrong variable.
fix
Ensure you await Cache.create() and then call methods on the resolved cache object.
TypeError: cache.get(...).then is not a function
cache.get returns a promise that resolves to the value, not the value directly.
fix
Use await or .then() to get the value. Example: const val = await cache.get('key');
Upgrade
Version history
4.1.1-alpha.0latest on npm
Audit
Dependencies
ioredisrequiredRequired for Redis connectivity and operations.
Agent activity
7 hits · last 30 days
node
6
Resources
data-point-cache — npm install data-point-cache · libregistry