#RedisScan
Recursively scans the keyspace of a Redis 2.8+ instance using SCAN, HSCAN, ZSCAN, & SSCAN as well as Lists.
Fairly safe in a production environment as it does NOT use KEYS * to iterate.
Optionally pass a redis pattern to filter from.
scanRedis(args)
args:
- redis: node-redis instance (required)
- pattern: optional wildcard key pattern
- each_callback: function (type, key, subkey, value, finish_callback) type may be string, hash, set, zset, list call finish_callback when done
- done_callback: called when done scanning
each_callback is called for every string, and every subkey/value in a container, so container keys may be called multiple times.
Example:
var redisScan = require('redisscan');
var redis = require('redis').createClient();
redisScan({
redis: redis,
each_callback: function (type, key, subkey, value, cb) {
console.log(type, key, subkey, value);
cb();
},
done_callback: function (err) {
console.log("-=-=-=-=-=--=-=-=-");
redis.quit();
}
});
If values are changing, there is no guarantee on value integrity. This is not atomic. I recommend using a lock pattern with this function.
npm install redisscan
License MIT (c) 2014 Nathanael C. Fritz