Skip to content

Instantly share code, notes, and snippets.

@alan
Created January 9, 2010 15:11
Show Gist options
  • Save alan/272938 to your computer and use it in GitHub Desktop.
Save alan/272938 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'redis'
adapter = Redis.new(:host => '127.0.0.1',
:port => 6379,
:thread_safe => true,
:db => 10)
adapter.flushdb
adapter.sadd("wanted", "foo")
adapter.sadd("wanted", "bar")
adapter.sadd("available", "foo")
adapter.sadd("available", "bar")
adapter.sadd("notified", "bar")
# Without this line, seems to work
adapter.expire("notified", 300)
adapter.sinterstore("result", "available", "wanted")
puts "SDIFF ::: #{adapter.sdiff('result', 'notified').inspect}"
adapter.sdiffstore("result2", "result", "notified")
puts "SDIFFSTORE ::: #{adapter.smembers('result2').inspect}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment