RedisZ v0.2.0 RedisZ View Source

Pooling & sharding support parallel Redis adapter base on Redix.

Start RedisZ in your application.

children = [
  {RedisZ, name: Example.Redis, pool_size: 4, urls: ["redis://localhost/0", "redis://localhost/1"]},
]

Call RedisZ like Redix.

"OK" = RedisZ.command!(Example.Redis, ["SETEX", "mykey", 10, "Hello"])
[10, "Hello"] = RedisZ.pipeline!(Example.Redis, [["TTL", "mykey"], ["GET", "mykey"]])

You can specify shard like Redis Cluster. {momonga}1 & {momonga}2 are stored at the same shard.

["OK", "OK"] = RedisZ.pipeline!(Example.Redis, ["SET", "{momonga}1", "Hello"], ["SET", "{momonga}2", "Hello"])

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor

Act like Redix.command!/3 through shards & connnection pool

Act like Redix.command/3 through shards & connnection pool

command/3 to each shards & collect the resutls

Act like Redix.pipeline!/3 through shards & connnection pool

Act like Redix.pipeline/3 through shards & connnection pool

pipeline/3 to each shards & collect the resutls

Link to this section Types

Link to this type args() View Source
args() :: [
  server_name: RedisZ.Server.name(),
  shards_name: RedisZ.Shards.name(),
  diagnoser_name: RedisZ.Diagnoser.name(),
  urls: [binary() | keyword()] | binary(),
  pool_size: pos_integer(),
  shards: [
    name: RedisZ.Shard.name(),
    diagnoser_name: RedisZ.Diagnoser.name(),
    pool_name: RedisZ.Pool.name(),
    pool_size: pos_integer()
  ]
]

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Act like Redix.command!/3 through shards & connnection pool.

Link to this function command(conn, command, opts \\ []) View Source
command(RedisZ.Server.name(), Redix.command(), keyword()) ::
  {:ok, Redix.Protocol.redis_value()} | {:error, atom() | Redix.Error.t()}

Act like Redix.command/3 through shards & connnection pool.

Link to this function command_to_all_shards(conn, command, opts \\ []) View Source
command_to_all_shards(RedisZ.Server.name(), Redix.command(), keyword()) :: %{
  optional(RedisZ.Shard.name()) =>
    {:ok, Redix.Protocol.redis_value()} | {:error, atom() | Redix.Error.t()}
}

command/3 to each shards & collect the resutls.

Link to this function pipeline!(conn, commands, opts \\ []) View Source

Act like Redix.pipeline!/3 through shards & connnection pool.

Link to this function pipeline(conn, commands, opts \\ []) View Source
pipeline(RedisZ.Server.name(), [Redix.command()], keyword()) ::
  {:ok, [Redix.Protocol.redis_value()]} | {:error, atom() | Redix.Error.t()}

Act like Redix.pipeline/3 through shards & connnection pool.

Link to this function pipeline_to_all_shards(conn, commands, opts \\ []) View Source
pipeline_to_all_shards(RedisZ.Server.name(), [Redix.command()], keyword()) :: %{
  optional(RedisZ.Shard.name()) =>
    {:ok, [Redix.Protocol.redis_value()]} | {:error, atom() | Redix.Error.t()}
}

pipeline/3 to each shards & collect the resutls.