Registry / database / abstract-cache-redis

abstract-cache-redis

JSON →
library2.0.0jsnpmunverified

An abstract-cache compliant Redis client that implements the await-style protocol. Version 2.0.0 wraps ioredis and provides methods like keys, scan, scanStream, disconnect, and quit on top of the standard abstract-cache API. It connects to localhost:6379 by default or accepts a pre-connected ioredis client. The package is feature-complete and sees low maintenance cadence; it is best used with abstract-cache to swap between different cache backends.

npm install abstract-cache-redis
INSTALL
IMPORT
SIG · ABSTRACT-CACHE-RED
A
abstract-cache-redis
databasejavascriptv2.0.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.

default (factory function)
const client = require('abstract-cache-redis')({ ioredis: {} })
const client = require('abstract-cache-redis')
The module exports a factory function that must be called with options.
CommonJS require
const cache = require('abstract-cache-redis')
import cache from 'abstract-cache-redis'
Package does not ship ESM; use require() or dynamic import().
client methods (set, get, has, keys)
client.set('key', 'value', 1000).then(() => client.has('key'))
client.set('key', 'value')
set() requires a TTL (third argument) in milliseconds; TTL is not optional.

Creates a Redis cache client, sets a key with TTL, checks existence, scans keys, and closes the connection.

const client = require('abstract-cache-redis')({ ioredis: { host: 'localhost', port: 6379 } }); async function main() { await client.set('foo', 'bar', 1000); const exists = await client.has('foo'); console.log('exists:', exists); // true const keys = await client.keys('fo*'); console.log('keys:', keys); // ['foo'] await client.quit(); } main().catch(console.error);
Debug
Known issues
gotchaset() requires TTL (in milliseconds) as third argument; omitting it causes unexpected behavior.
fix
Always pass a numeric TTL (e.g., 1000 for 1 second).
affects: >=1.0.0
gotchaClient must be created with either `ioredis` config or a pre-connected `client` instance; passing empty object throws.
fix
Provide at least one of `ioredis` or `client` options.
affects: >=1.0.0
gotchaThe user is responsible for closing the connection; not calling `quit()` or `disconnect()` leaves resources open.
fix
Call `client.quit()` or `client.disconnect()` when done.
affects: >=1.0.0
deprecatedThe `scan` and `scanStream` methods are not part of the abstract-cache spec and may be removed.
fix
Avoid relying on these methods; use abstract-cache's standard `keys` instead.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'abstract-cache-redis'
The package is not installed or not resolved correctly.
fix
Run `npm install abstract-cache-redis` and ensure node_modules is available.
TypeError: client.set is not a function
Client factory was not called; `require('abstract-cache-redis')` returns a constructor, not a client.
fix
Call the factory: `require('abstract-cache-redis')({ ioredis: {} })`.
ReplyError: WRONGTYPE Operation against a key holding the wrong kind of value
Key already exists with a different data type (e.g., list instead of string).
fix
Delete the key (`client.del('key')`) or ensure key type matches.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
abstract-cacherequiredDefines the cache interface/protocol that this client implements.
ioredisrequiredRedis client library used internally for all Redis operations.
Agent activity
59 hits · last 30 days
node
50
OpenAI (training)
1
Resources
abstract-cache-redis — npm install abstract-cache-redis · libregistry