playing
This commit is contained in:
commit
ca5596e219
4
redis-with-ruby/Gemfile
Normal file
4
redis-with-ruby/Gemfile
Normal file
@ -0,0 +1,4 @@
|
||||
source :rubygems
|
||||
|
||||
gem 'hiredis'
|
||||
gem 'redis'
|
12
redis-with-ruby/Gemfile.lock
Normal file
12
redis-with-ruby/Gemfile.lock
Normal file
@ -0,0 +1,12 @@
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
hiredis (0.4.4)
|
||||
redis (2.2.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
hiredis
|
||||
redis
|
35
redis-with-ruby/in-and-out.rb
Normal file
35
redis-with-ruby/in-and-out.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user