Skip to content

Instantly share code, notes, and snippets.

@tblobaum
Created July 24, 2012 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tblobaum/3170212 to your computer and use it in GitHub Desktop.
Save tblobaum/3170212 to your computer and use it in GitHub Desktop.
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