Getting Started With Redis in Ruby

Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

To get started first we need is gem 'redis'. Open up irb console. Now working with redis is as simple as :

require 'redis'

redis_connection = => 0)
=> #<Redis client v3.0.7 for redis://>

redis_connection.set("key", "value")
=> "OK"

=> "value"

=> 1

=> nil # As we have delete the key value from redis memory.

By default our redis connection is connected to localhost, but we can specify the server ip where we want redis connection to be established.

redis_connection = => 0, :host =>

Make sure redis on is running and accepting connections from outside , other than localhost.

For more detailed list of commands for redis check here.