class

Redis

Inherits Redis::CommandExecution::ValueOriented < Redis::Commands < Reference < Object

The class is the main entry point for the Redis client.

How to use:

Require the package:

require "redis"

Then instantiate this client class:

redis = Redis.new

Then you can call Redis commands on the redis object:

redis.set("foo", "bar")
redis.get("foo")
redis.incr("visitors")

See the mixin module Commands for most of the available Redis commands such as #incr, #rename, and so on.

Multithreading / Coroutines

Please mind that a Redis object can't be shared across multiple threads/coroutines! Each thread/coroutine that wants to talk to Redis needs its own Redis object instance.

Constructors

new(host : String = "localhost", port : Int32 = 6379, unixsocket : String | Nil = nil, password : String | Nil = nil, database : Int32 | Nil = nil, url = nil, ssl : Bool = false, ssl_context : OpenSSL::SSL::Context::Client | Nil = nil, dns_timeout : Time::Span | Nil = nil, connect_timeout : Time::Span | Nil = nil, reconnect : Bool = true, command_timeout : Time::Span | Nil = nil, role : String | Nil = "master", sentinels : Array(Hash(Symbol, String | Int32)) | Nil = nil)

new overloaded constructor allowing sentinel config

Source

Instance methods

resolve_master

find a master Redis instance via a given sentinel ported from Redis::Client::Connector::Sentinel#resolve_master

Source
resolve_sentinel

finds appropriate Redis instance via Sentinel ported from Redis::Client::Connector::Sentinel#resolve

Source
resolve_slave

find a slave Redis instance via a given sentinel ported from Redis::Client::Connector::Sentinel#resolve_slave

Source
sentinel_detect

sentinel checker, attempts connection to potential sentinels and passes viable candidate to block ported from Redis::Client::Connector::Sentinel#sentinel_detect

Source

Nested types