class Redis::PooledClient

Overview

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.

Defined in:

redis/pooled_client.cr

Constructors

Instance Method Summary

Macro Summary

Constructor Detail

def self.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.

[View source]

Instance Method Detail

def pool : ConnectionPool(Redis) #

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


[View source]
def psubscribe(*channel_patterns, &callback_setup_block : Redis::Subscription -> ) #

[View source]
def subscribe(*channels, &callback_setup_block : Redis::Subscription -> ) #

[View source]

Macro Detail

macro method_missing(call) #

[View source]