class

Redis::PooledClient

Inherits Reference / Object

A Redis client object that can be shared across multiple fibers. It is backed by a connection pool of Redis instances and will automatically allocate and free these instances from/to the pool, per command.

Example usage:

redis = Redis::PooledClient.new(host: ..., port: ..., ..., pool_size: 5)
10.times do |i|
  spawn do
    redis.set("foo#{i}", "bar")
    redis.get("foo#{i}") # => "bar"
  end
end

Here 10 fibers access the same Redis::PooledClient instance while automatically sharing 5 Redis connections.

Constructors

new(*args, pool_size = 5, pool_timeout = 5.0, **args2)

Accepts the same connection parameters like a Redis instance, plus the documented ones.

  • pool_size - the number of Redis to hold in the connection pool.
  • pool_timeout - the time to wait for a Redis instance to become available from the pool before dying with Redis::PoolTimeoutError.
Source

Instance methods

pool

The connection pool. See https://github.com/ysbaddaden/pool

Source
psubscribe(*channel_patterns, &callback_setup_block : Redis::Subscription -> )
Source
subscribe(*channels, &callback_setup_block : Redis::Subscription -> )
Source

Macros

method_missing(call)
Source