Registry / database / redis-async-gen

redis-async-gen

JSON →
library0.1.3jsnpmunverified

A small library (v0.1.3) that wraps Redis SCAN operations into async generators, simplifying key scanning in Redis databases. It handles cursor management and pagination, allowing developers to use `for await...of` loops instead of manual iteration. Released sporadically, it supports scanning keys by pattern and scanning set values by pattern. Compared to alternatives like ioredis, it provides a simpler generator-based API but lacks active maintenance and wide adoption.

npm install redis-async-gen
INSTALL
IMPORT
SIG · REDIS-ASYNC-GEN
R
redis-async-gen
databasejavascriptv0.1.3
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.

keysMatching
const { keysMatching } = generators.using(client)
const { keysMatching } = require('redis-async-gen')
keysMatching is obtained via the using(client) factory, not directly from the package.
valuesMatching
const { valuesMatching } = generators.using(client)
const { valuesMatching } = require('redis-async-gen')
valuesMatching is also obtained via using(client) factory for set scanning.
using
const generators = require('redis-async-gen'); const { using } = generators
const { using } = require('redis-async-gen')
using is a property of the default export object. Check README for exact pattern.

Connects to Redis, scans keys matching 'test*' using async generator, logs each key.

const redis = require('redis'); const client = redis.createClient({ url: process.env.REDIS_URL || 'redis://localhost:6379' }); const generators = require('redis-async-gen'); const { keysMatching } = generators.using(client); async function main() { await client.connect(); for await (const key of keysMatching('test*')) { console.log('Found key:', key); } await client.quit(); } main().catch(console.error);
Debug
Known issues
gotchaThe package wraps the `redis` npm package (v3 or v4). It does not support ioredis.
fix
Use the `redis` package (not ioredis) as the client.
affects: >=0.0.0
gotchaThe generator does not handle disconnections or errors from Redis gracefully; any error will bubble up and break the loop.
fix
Wrap the for-await loop in try-catch to handle Redis errors.
affects: >=0.0.0
deprecatedThe package is not actively maintained; last release was in 2020. No support for Redis v4 client promise-based API.
fix
Consider alternatives like ioredis or node-redis-streams.
affects: <=0.1.3
Errors
Common errors & fixes
TypeError: generators.using is not a function
Importing `using` directly from the package instead of from the default export.
fix
Use `const generators = require('redis-async-gen'); const { using } = generators;`
TypeError: keysMatching is not a function
Calling keysMatching without first calling using(client).
fix
Const { keysMatching } = generators.using(client); then keysMatching(pattern) works.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies
redisrequiredPeer dependency for connecting to Redis; the library wraps redis client methods.
Agent activity
9 hits · last 30 days
node
8
Meta
1
Resources
redis-async-gen — npm install redis-async-gen · libregistry