Skip to content

Commit

Permalink
Issue # 1697 FIX - creates an example script that shows how to use th…
Browse files Browse the repository at this point in the history
…e 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 <simon@redislabs.com>

Closes #1697.
  • Loading branch information
shashank19aug committed Oct 27, 2021
1 parent fdffa23 commit d409120
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/README.md
Expand Up @@ -8,6 +8,7 @@ This folder contains example scripts showing how to use Node Redis in different
| `blocking-list-pop.js` | Block until an element is pushed to a list |
| `lua-multi-incr.js` | Define a custom lua script that allows you to perform INCRBY on multiple keys |
| `command-with-modifiers.js` | Define a script that allows to run a command with several modifiers |
| `set-scan.js` | An example script that shows how to use the SSCAN iterator functionality |

## Contributing

Expand Down
19 changes: 19 additions & 0 deletions examples/set-scan.js
@@ -0,0 +1,19 @@
// An example script that shows how to use the SSCAN iterator functionality to retrieve the contents of a Redis set.
// Create the set in redis-cli with this command:
// sadd setName a b c d e f g h i j k l m n o p q

import { createClient } from 'redis';

async function setScan() {
const client = createClient();
await client.connect();

const setName = 'setName';
for await (const member of client.sScanIterator(setName)) {
console.log(member);
}

await client.quit();
}

setScan();

0 comments on commit d409120

Please sign in to comment.