Redis::PooledClient
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
Redisto hold in the connection pool. - pool_timeout - the time to wait for a
Redisinstance to become available from the pool before dying withRedis::PoolTimeoutError.
Instance methods
psubscribe(*channel_patterns, &callback_setup_block : Redis::Subscription -> )
Sourcesubscribe(*channels, &callback_setup_block : Redis::Subscription -> )
SourceMacros
method_missing(call)
Source