This commit is contained in:
Dan Buch 2012-02-28 01:26:08 -05:00
commit ca5596e219
3 changed files with 51 additions and 0 deletions

4
redis-with-ruby/Gemfile Normal file
View File

@ -0,0 +1,4 @@
source :rubygems
gem 'hiredis'
gem 'redis'

View File

@ -0,0 +1,12 @@
GEM
remote: http://rubygems.org/
specs:
hiredis (0.4.4)
redis (2.2.2)
PLATFORMS
ruby
DEPENDENCIES
hiredis
redis

View File

@ -0,0 +1,35 @@
require 'redis/connection/hiredis'
require 'redis'
require 'yaml'
class Fancy
attr_accessor :has_pants, :likes_to_dance
def initialize(has_pants)
@has_pants = has_pants
@likes_to_dance = true
end
end
def main
redis = Redis.new
inst = Fancy.new('yup!')
puts redis.set('foo', 'bar')
puts redis.set('derp', inst.to_yaml)
puts redis.sadd('hamsters', 'albert')
puts redis.sadd('hamsters', 'walter')
puts redis.get('foo')
puts YAML.load_documents(redis.get('derp'))[0]
puts redis.sinter('hamsters')
end
if $0 == __FILE__
main
end