You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> :warning: The command options API in v5 has breaking changes from the previous version. For more details, refer to the [v4-to-v5 guide](./v4-to-v5.md#command-options).
> :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).
4
+
5
+
[`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):
6
+
7
+
```typescript
8
+
forawait (const keys ofclient.scanIterator()) {
9
+
const values =awaitclient.mGet(keys);
10
+
}
11
+
```
12
+
13
+
This works with `HSCAN`, `SSCAN`, and `ZSCAN` too:
`withCommandOptions` can be used to override all of the command options, without reusing any existing ones.
34
34
35
35
To override just a specific option, use the following functions:
36
-
-`withFlags` - override `flags` only.
36
+
-`withTypeMapping` - override `typeMapping` only.
37
+
-`withAbortSignal` - override `abortSignal` only.
37
38
-`asap` - override `asap` to `true`.
38
39
-`isolated` - override `isolated` to `true`.
39
40
41
+
[TODO](./command-options.md)
42
+
40
43
## Quit VS Disconnect
41
44
42
45
The `QUIT` command has been deprecated in Redis 7.2 and should now also be considered deprecated in Node-Redis. Instead of sending a `QUIT` command to the server, the client can simply close the network connection.
@@ -45,9 +48,24 @@ The `QUIT` command has been deprecated in Redis 7.2 and should now also be consi
45
48
46
49
## Scan Iterators
47
50
48
-
TODO
49
-
Yields chunks instead of individual items. Allows multi key operations.
50
-
See the [Scan Iterators guide](./scan-iterators.md).
51
+
Iterator commands like `SCAN`, `HSCAN`, `SSCAN`, and `ZSCAN` return collections of elements (depending on the data type). However, v4 iterators loop over these collections and yield individual items:
52
+
53
+
```javascript
54
+
forawait (constkeyofclient.scanIterator()) {
55
+
console.log(key, awaitclient.get(key));
56
+
}
57
+
```
58
+
59
+
This mismatch can be awkward and makes "multi-key" commands like `MGET`, `UNLINK`, etc. pointless. So, in v5 the iterators now yield a collection instead of an element:
60
+
61
+
```javascript
62
+
forawait (constkeysofclient.scanIterator()) {
63
+
// we can now meaningfully utilize "multi-key" commands
64
+
console.log(keys, awaitclient.mGet(keys));
65
+
}
66
+
```
67
+
68
+
for more information, see the [Scan Iterators guide](./scan-iterators.md).
0 commit comments