Skip to content

Commit d409120

Browse files
Issue # 1697 FIX - creates an example script that shows how to use the SSCAN iterator (#1699)
* #1697 fix for set scan example * adds the js file * adds comment * Minor layout and comment adjustment. Co-authored-by: srawat2 <shashank19aug> Co-authored-by: Simon Prickett <[email protected]> Closes #1697.
1 parent fdffa23 commit d409120

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This folder contains example scripts showing how to use Node Redis in different
88
| `blocking-list-pop.js` | Block until an element is pushed to a list |
99
| `lua-multi-incr.js` | Define a custom lua script that allows you to perform INCRBY on multiple keys |
1010
| `command-with-modifiers.js` | Define a script that allows to run a command with several modifiers |
11+
| `set-scan.js` | An example script that shows how to use the SSCAN iterator functionality |
1112

1213
## Contributing
1314

examples/set-scan.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// An example script that shows how to use the SSCAN iterator functionality to retrieve the contents of a Redis set.
2+
// Create the set in redis-cli with this command:
3+
// sadd setName a b c d e f g h i j k l m n o p q
4+
5+
import { createClient } from 'redis';
6+
7+
async function setScan() {
8+
const client = createClient();
9+
await client.connect();
10+
11+
const setName = 'setName';
12+
for await (const member of client.sScanIterator(setName)) {
13+
console.log(member);
14+
}
15+
16+
await client.quit();
17+
}
18+
19+
setScan();

0 commit comments

Comments
 (0)