September 2015
Beginner to intermediate
230 pages
4h 47m
English
Redis has an official Ruby client, redis-rb, and this is the client used in this section.
Installing it:
$ gem install redis
In this section, the Ruby code has comments that represent the result of the previous expression. It is recommended to run all of the code from this section in the interactive Ruby interpreter (irb in the command line).
The interface of redis-rb is very close to how you interact with Redis through redis-cli:
require 'redis' @redis = Redis.new(:host => "127.0.0.1", :port => 6379) @redis.set "string:my_key", "Hello World" @redis.get "string:my_key" # => "Hello World" @redis.incr "string:counter" @redis.mget ["string:my_key", "string:counter"] # => ["Hello World", "1"] @redis.rpush "list:my_list", ...
Read now
Unlock full access