box-o-sand/redis/in-and-out.rb
2012-04-03 23:02:32 -04:00

39 lines
639 B
Ruby

require 'redis/connection/hiredis'
require 'redis'
require 'pp'
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!')
['foo', 'derp', 'hamsters'].each { |k| redis.del(k) }
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')
pp YAML.load_documents(redis.get('derp'))[0]
puts redis.smembers('hamsters')
end
if $0 == __FILE__
main
end