Registry / database / redis-scanner

redis-scanner

JSON →
library0.1.1jsnpmunverified

redis-scanner (v0.1.1) is a Node.js utility that wraps Redis SCAN, SSCAN, HSCAN, and ZSCAN commands to simplify iteration over large key sets without blocking the server. It supports both synchronous and asynchronous usage, and offers two integration methods: binding scan methods directly to a RedisClient instance, or creating standalone Scanner objects. Currently pre-1.0.0, with potential breaking changes, it is no longer actively maintained (last commit in 2016). Key differentiators: automatic cursor management, MATCH/COUNT options in `options`, and reusable Scanner objects. Not compatible with modern Redis clients; prefer `ioredis` or `node-redis` built-in scan iterators.

npm install redis-scanner
INSTALL
IMPORT
SIG · REDIS-SCANNER
R
redis-scanner
databasejavascriptv0.1.1
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.

bindScanners
const { bindScanners } = require('redis-scanner');
import { bindScanners } from 'redis-scanner';
CJS-only; no ESM support. Do not use ES import syntax.
Scanner
const { Scanner } = require('redis-scanner');
import { Scanner } from 'redis-scanner';
Same as above – CJS only. Use with new Scanner(client, type, key, options).
default import
const redis_scanner = require('redis-scanner');
const redis_scanner = require('redis-scanner').default;
The module exports an object with bindScanners and Scanner. There is no default export.

Demonstrates two ways to use redis-scanner: binding scan methods to a Redis client, and creating a standalone Scanner with options like pattern and count.

const redis = require('redis'); const { bindScanners, Scanner } = require('redis-scanner'); const client = redis.createClient(process.env.REDIS_URL ?? ''); // Approach 1: bind methods to client bindScanners(client); client.scan('0', 'MATCH', 'user:*', 'COUNT', 10, function(result, done) { console.log('Matched keys:', result); done(); }, function(err) { console.error(err); client.quit(); }); // Approach 2: direct Scanner const scanner = new Scanner(client, 'SCAN', null, { pattern: 'user:*', count: 10, onData: function(result, done) { console.log('Keys:', result); done(); }, onEnd: function(err) { console.log('Done'); client.quit(); } }); scanner.start();
Debug
Known issues
breakingPre-1.0.0: breaking changes may occur without major version bump.
fix
Pin to an exact version (e.g., 0.1.1) and test upgrades.
affects: <1.0
gotchaNode-redis v4+ changed client API; bindScanners expects deprecated v2/v3 style. May not work with modern redis package.
fix
Use redis v3 (npm install redis@3) or switch to built-in scanIterator in node-redis v4+.
affects: >=4.0
deprecatedProject abandoned since 2016; no updates for security or compatibility.
fix
Migrate to ioredis or node-redis v4+ scan utilities.
affects: *
gotchaonData callback: if no second argument (done), scanner will not await async processing and may skip subsequent chunks.
fix
Always accept and call the done callback for async processing.
affects: <=0.1.1
gotchaScanner reuse: do not run the same scanner instance concurrently; it will cause cursor overlap.
fix
Create a new Scanner for each concurrent scan, or await onEnd before reusing.
affects: *
Errors
Common errors & fixes
TypeError: client.scan is not a function
bindScanners was not called on the Redis client instance.
fix
Call bindScanners(client) after creating the client and before using scan/hscan/sscan/zscan.
TypeError: redis_scanner.Scanner is not a constructor
Using ES import 'import { Scanner } ...' on a CJS module that exports an object, not a named export.
fix
Use require('redis-scanner').Scanner or const { Scanner } = require('redis-scanner').
ReplyError: ERR wrong number of arguments for 'scan' command
Providing both `args` and `pattern`/`count` in options, causing duplicate arguments.
fix
Use only one: either provide `args` array or use `pattern` and `count` options (not both).
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
redisrequiredThe package binds to and requires a redis.RedisClient instance. It does not work with ioredis or other clients.
Agent activity
18 hits · last 30 days
node
16
Amazon
1
Resources
redis-scanner — npm install redis-scanner · libregistry