ExRedisPool v0.2.1 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

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

Like qp/3 except returns the result directly or raises an error

Run an asynchronous query pipeline

Types

mapper()
mapper() :: atom | pid
pool()
pool() :: atom | pid
reason()
reason() :: binary
reconnect_sleep()
reconnect_sleep() :: :no_reconnect | integer
redis_pool_option()
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_pool_options()
redis_pool_options() :: [redis_pool_option]
redis_query()
redis_query() :: [binary]
redis_result()
redis_result() :: binary | :undefined

Functions

new(shard_opts_list)
new([redis_pool_options]) :: pid

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.

new(mapper, shard_opts_list)
new(mapper, [redis_pool_options]) :: pid

Like new/1 but with the option to give an atom name.

q(mapper, query, shard_key, timeout \\ 5000)
q(mapper, redis_query, binary, integer) ::
  {:ok, redis_result} |
  {:error, reason}

Run a synchronous redis query (sharded).

q!(mapper, query, shard_key, timeout \\ 5000)
q!(mapper, redis_query, binary, integer) ::
  redis_result |
  no_return

Like q/3 except returns the result directly or raises an error (sharded).

q_noreply(mapper, query, shard_key)
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.

qp(mapper, query_pipeline, shard_key, timeout \\ 5000)
qp(mapper, [redis_query], binary, integer) ::
  [{:ok, redis_result}] |
  {:error, reason}

Run a synchronous query pipeline.

qp!(mapper, query_pipeline, shard_key, timeout \\ 5000)
qp!(mapper, [redis_query], binary, integer) ::
  [redis_result] |
  no_return

Like qp/3 except returns the result directly or raises an error.

qp_noreply(mapper, query_pipeline, shard_key)
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.

start_link(opts \\ [])