Created
July 24, 2012 14:26
-
-
Save tblobaum/3170212 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Redis = require('redis-stream') | |
, client = new Redis('localhost', 6379, 0) | |
, stream = client.stream() | |
// this will get an intersection of all the elements in | |
// `set1`, `set2` & `set3` and then it will use each of the members | |
// in the resulting intersection as a key in a `sinter` with `subset1` | |
// and each of those resulting sets will be piped to stdout | |
// this will not use pipelining and will call `sinter subset1 member` once | |
// for every member of the original intersection | |
stream | |
.pipe(client.stream('sinter', 'subset1')) | |
.pipe(process.stdout) | |
// if you want `sinter` here to function as `sinterstore` | |
// while still returning the resulting set, then you can | |
// also save this to another set like `sinterstore` does | |
stream.pipe(client.stream('sadd', 'my-sinterstore-result-store')) | |
// kick it off | |
stream.redis.write(Redis.parse([ 'sinter', 'set1', 'set2', 'set3' ])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment