ExRedisPool v0.1.0 ExRedisPool.Shard
Interface module for working with sharded Redis clusters.
Supervisor for ShardMappers.
Each child of this supervisor is a process that maps queries to their appropriate Redis shard.
In this context, a shard is simply a RedisPool process. By combining a group of RedisPool processes we can map a workload onto more than one instance of Redis.
Summary
Functions
Callback implementation for c::supervisor.init/1
Start a new shard_mapper
Like new/1
but with the option to give an atom name
Run a synchronous redis query (sharded)
Like q/3 except returns the result directly or raises an error (sharded)
Run an asynchronous redis query
Run a synchronous query pipeline
Like qp/3 except returns the result directly or raises an error
Run an asynchronous query pipeline
Types
mapper :: atom | pid
pool :: atom | pid
reason :: binary
reconnect_sleep :: :no_reconnect | integer
redis_pool_option ::
{:host, binary} |
{:port, integer} |
{:database, binary} |
{:password, binary} |
{:reconnect_sleep, reconnect_sleep} |
{:sync_pool_size, integer} |
{:sync_pool_max_overflow, integer} |
{:async_pool_size, integer} |
{:async_pool_max_overflow, integer}
redis_query :: [binary]
redis_result :: binary | :undefined
Functions
Specs
new([redis_pool_options]) ::
{:ok, pool} |
{:error, reason}
Start a new shard_mapper.
Takes a list of connection options for each shard. Each shard is assigned an index based on the order of the connection options.
Specs
new(mapper, [redis_pool_options]) ::
{:ok, pool} |
{:error, reason}
Like new/1
but with the option to give an atom name.
Specs
q(mapper, redis_query, binary, integer) ::
{:ok, redis_result} |
{:error, reason}
Run a synchronous redis query (sharded).
Specs
q!(mapper, redis_query, binary, integer) ::
redis_result |
no_return
Like q/3 except returns the result directly or raises an error (sharded).
Specs
q_noreply(mapper, redis_query, binary) ::
:ok |
{:error, reason}
Run an asynchronous redis query.
This function takes the requested query and queues it in a separate pool from the synchronous queries so bulk asynchronous queries do not degrade quality of service for synchronous queries.
Specs
qp(mapper, [redis_query], binary, integer) ::
[{:ok, redis_result}] |
{:error, reason}
Run a synchronous query pipeline.
Specs
qp!(mapper, [redis_query], binary, integer) ::
[redis_result] |
no_return
Like qp/3 except returns the result directly or raises an error.
Specs
qp_noreply(mapper, [redis_query], binary) ::
:ok |
{:error, reason}
Run an asynchronous query pipeline.
This function takes the requested query pipeline and queues it in a separate pool from the synchronous query pipelines so bulk asynchronous query pipelines do not degrade quality of service for synchronous query pipelines.