Skip to content

Issue # 1697 FIX - creates an example script that shows how to use the SSCAN iterator #1699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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();