box-o-sand/redis-with-ruby/in-and-out.rb

36 lines
569 B
Ruby
Raw Normal View History

2012-02-28 06:26:08 +00:00
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