Connection pool for Redis.
Manages N Redis.Connection processes with round-robin dispatch.
Dead connections are automatically replaced. Same API as a single connection.
Usage
{:ok, pool} = Redis.Connection.Pool.start_link(
pool_size: 5,
host: "localhost",
port: 6379
)
{:ok, "OK"} = Redis.Connection.Pool.command(pool, ["SET", "key", "val"])
{:ok, "val"} = Redis.Connection.Pool.command(pool, ["GET", "key"])Options
:pool_size- number of connections (default: 5):strategy-:round_robinor:random(default::round_robin):name- GenServer name- All other options are passed to each
Redis.Connection
Supervision
children = [
{Redis.Connection.Pool, pool_size: 10, port: 6379, name: :redis_pool}
]
Summary
Functions
Returns a specification to start this module under a supervisor.
Returns pool info: size, active connections, strategy.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec command(GenServer.server(), [String.t()], keyword()) :: {:ok, term()} | {:error, term()}
@spec info(GenServer.server()) :: map()
Returns pool info: size, active connections, strategy.
@spec noreply_command(GenServer.server(), [String.t()], keyword()) :: :ok | {:error, term()}
@spec noreply_pipeline(GenServer.server(), [[String.t()]], keyword()) :: :ok | {:error, term()}
@spec pipeline(GenServer.server(), [[String.t()]], keyword()) :: {:ok, [term()]} | {:error, term()}
@spec start_link(keyword()) :: GenServer.on_start()
@spec stop(GenServer.server()) :: :ok
@spec transaction(GenServer.server(), [[String.t()]], keyword()) :: {:ok, [term()]} | {:error, term()}