# redisscan

> Scan through all redis keys and containers, calling back each value individually.

Latest version **2.0.0** (published 2017-04-07) · 0 weekly downloads

## Install

```sh
npm install redisscan
pnpm add redisscan
yarn add redisscan
bun add redisscan
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2017-04-07 |
| First published | 2014-02-11 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 22 |
| Maintainers | fritzy |

## Links

- npm: https://www.npmjs.com/package/redisscan
- Repository: https://github.com/fritzy/node-redisscan
- Issues: https://github.com/fritzy/node-redisscan/issues
- npm.io page: https://npm.io/package/redisscan

## Dependencies (2)

- [async](https://npm.io/package/async.md) ~0.2.10
- [redis](https://npm.io/package/redis.md) ^2.7.1

## Recent versions

- 2.0.0 (latest) — 2017-04-07
- 1.1.0 — 2014-02-17
- 1.0.0 — 2014-02-11

## README

# 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.

## Install
`npm install redisscan`

## Example 

```javascript
var redisScan = require('redisscan');
var redis     = require('redis').createClient();


redisScan({
    redis: redis,
    pattern: 'awesome:key:prefix:*',
    keys_only: false,
    each_callback: function (type, key, subkey, length, value, cb) {
        console.log(type, key, subkey, length, value);
        cb();
    },
    done_callback: function (err) {
        console.log("-=-=-=-=-=--=-=-=-");
        redis.quit();
    }
});
```

### redisScan(parameters):

* `redis`: **required** `node-redis` client instance 
* `pattern`: **optional** wildcard key pattern to match, e.g: `some:key:pattern:*` [docs](https://redis.io/commands/scan#the-match-option)
* `keys_only`: **optional** boolean -- returns nothing but keys, no types,lengths,values etc. (defaults to `false`)
* `count_amt`: **optional** positive/non-zero integer -- redis hint for work done per SCAN operation (defaults to 10) [docs](https://redis.io/commands/scan#the-count-option)
* `each_callback`: **required** `function (type, key, subkey, length, value, next)`  This is called for every string, and every subkey/value in a container when not using `keys_only`, so outer keys may show up multiple times.
    * `type` may be `"string"`, `"hash"`, `"set"`, `"zset"`, `"list"`
    * `key` is the redis key
    * `subkey` may be `null` or populated with a hash key
    * `length` is the length of a set or list
    * `value` is the value of the key or subkey when appropriate
    * `next()` should be called as a function with no arguments if successful or an `Error` object if not.
* `done_callback`: **optional** function called when scanning completes with one argument, and `Error` object if an error ws raised

## Note/Warning

If values are changing, there is no guarantee on value integrity. This is not atomic.
I recommend using a lock pattern with this function.



License MIT (c) 2014 Nathanael C. Fritz

---
_Source: https://npm.io/package/redisscan · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
