cat snippets

How to install and use Redis with Ruby

Tagged redis, ruby, key-value, database, cat  Languages ruby

Redis and redis-rb example:

git clone git://
cd redis-rb/
rake redis:install
rake dtach:install
rake redis:start &
rake install

cat <<EOF >>test.rb
require 'rubygems'
require 'redis'

r =


p'set foo to "bar"'
r['foo'] = 'bar'

p 'value of foo'
p r['foo']

ruby test.rb

If Redis is not started Ruby will exit at for some reason without saying anything.