https://github.com/simonprickett/redis-sscan-with-generator
Using the Redis SSCAN command with a JavaScript generator function.
https://github.com/simonprickett/redis-sscan-with-generator
generator-function generator-functions medium-article redis
Last synced: 28 days ago
JSON representation
Using the Redis SSCAN command with a JavaScript generator function.
- Host: GitHub
- URL: https://github.com/simonprickett/redis-sscan-with-generator
- Owner: simonprickett
- License: mit
- Created: 2019-10-24T05:01:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-27T17:53:35.000Z (about 5 years ago)
- Last Synced: 2025-09-07T07:03:41.733Z (9 months ago)
- Topics: generator-function, generator-functions, medium-article, redis
- Language: JavaScript
- Homepage: https://simonprickett.dev/
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# redis-sscan-with-generator
See my blog post about this [here](https://simonprickett.dev/exploring-javascript-generators-with-redis-sets/).
## Description
Example using a [JavaScript generator function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) to retrieve members from a Redis set using the [SSCAN](https://redis.io/commands/sscan) command.
## Setup
You will need to be running Redis at 127.0.0.1:6379, or change `index.js` to point at your Redis server.
## Usage
```
$ npm install
$ npm start
```
## Expected Output
The generator should fire three times before Redis has no more set members to return:
```
Retrieved: shark,viper,herbie,phoenix,sierra,geordie,bear,rocky,ghost,mcqueen,iceman,maverick
Retrieved: vader,crockett,mule,tiger,charlie,panther,rico,wolf,tubbs,astronaut
Retrieved: shepherd,phantom,ripley
```