From ca5596e2190b8acd41f17fe9e7a3809ac863e2d7 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Tue, 28 Feb 2012 01:26:08 -0500 Subject: [PATCH] playing --- redis-with-ruby/Gemfile | 4 ++++ redis-with-ruby/Gemfile.lock | 12 ++++++++++++ redis-with-ruby/in-and-out.rb | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 redis-with-ruby/Gemfile create mode 100644 redis-with-ruby/Gemfile.lock create mode 100644 redis-with-ruby/in-and-out.rb diff --git a/redis-with-ruby/Gemfile b/redis-with-ruby/Gemfile new file mode 100644 index 0000000..867d43f --- /dev/null +++ b/redis-with-ruby/Gemfile @@ -0,0 +1,4 @@ +source :rubygems + +gem 'hiredis' +gem 'redis' diff --git a/redis-with-ruby/Gemfile.lock b/redis-with-ruby/Gemfile.lock new file mode 100644 index 0000000..65d817f --- /dev/null +++ b/redis-with-ruby/Gemfile.lock @@ -0,0 +1,12 @@ +GEM + remote: http://rubygems.org/ + specs: + hiredis (0.4.4) + redis (2.2.2) + +PLATFORMS + ruby + +DEPENDENCIES + hiredis + redis diff --git a/redis-with-ruby/in-and-out.rb b/redis-with-ruby/in-and-out.rb new file mode 100644 index 0000000..950e8ec --- /dev/null +++ b/redis-with-ruby/in-and-out.rb @@ -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