You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
V5 bringing RESP3, Sentinel and TypeMapping to node-redis
RESP3 Support - Some commands responses in RESP3 aren't stable yet and therefore return an "untyped" ReplyUnion. Sentinel TypeMapping Correctly types Multi commands Note: some API changes to be further documented in v4-to-v5.md
This commit is contained in:
30
docs/scan-iterators.md
Normal file
30
docs/scan-iterators.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Scan Iterators
|
||||
|
||||
> :warning: The scan iterators API in v5 has breaking changes from the previous version. For more details, refer to the [v4-to-v5 guide](./v4-to-v5.md#scan-iterators).
|
||||
|
||||
[`SCAN`](https://redis.io/commands/scan) results can be looped over using [async iterators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator):
|
||||
|
||||
```javascript
|
||||
for await (const keys of client.scanIterator()) {
|
||||
const values = await client.mGet(keys);
|
||||
}
|
||||
```
|
||||
|
||||
This works with `HSCAN`, `SSCAN`, and `ZSCAN` too:
|
||||
|
||||
```javascript
|
||||
for await (const entries of client.hScanIterator('hash')) {}
|
||||
for await (const members of client.sScanIterator('set')) {}
|
||||
for await (const membersWithScores of client.zScanIterator('sorted-set')) {}
|
||||
```
|
||||
|
||||
You can override the default options by providing a configuration object:
|
||||
|
||||
```javascript
|
||||
client.scanIterator({
|
||||
cursor: '0', // optional, defaults to '0'
|
||||
TYPE: 'string', // `SCAN` only
|
||||
MATCH: 'patter*',
|
||||
COUNT: 100
|
||||
});
|
||||
```
|
Reference in New Issue
Block a user