View Source LibRedis.Pool (lib_redis v0.1.0)

libredis-pool

LibRedis.Pool

Wrap redix with nimble_pool

usage

Usage

iex> pool = LibRedis.Pool.new(name: :redis_pool, pool_size: 5, url: "redis://:123456@localhost:6379")
iex> {:ok, _} = LibRedis.Pool.start_link(pool: pool)
iex> LibRedis.Pool.command(pool, ["SET", "foo", "bar"])
{:ok, "OK"}
iex> LibRedis.Pool.pipeline(pool, [["SET", "foo", "bar"], ["SET", "bar", "foo"]])
{:ok, ["OK", "OK"]]}

Link to this section Summary

Functions

delegate to Redix.command/2

create new redis pool instance

delegate to Redix.pipeline/2

start redis with nimble pool

Link to this section Types

@type command_t() :: [binary() | bitstring()]
@type t() :: %LibRedis.Pool{
  name: GenServer.name(),
  pool_size: non_neg_integer(),
  url: String.t()
}

Link to this section Functions

Link to this function

command(pool, command, opts \\ [])

View Source
@spec command(t(), command_t(), keyword()) :: {:ok, term()} | {:error, term()}

delegate to Redix.command/2

examples

Examples

iex> LibRedis.Pool.command(pool, ["SET", "foo", "bar"])
{:ok, "OK"}
@spec new(keyword()) :: t()

create new redis pool instance

examples

Examples

iex> LibRedis.Pool.new()
Link to this function

pipeline(pool, commands, opts \\ [])

View Source
@spec pipeline(t(), [command_t()], keyword()) :: {:ok, term()} | {:error, term()}

delegate to Redix.pipeline/2

examples

Examples

iex> LibRedis.Pool.pipeline(pool, [["SET", "foo", "bar"], ["SET", "bar", "foo"]])
{:ok, ["OK", "OK"]]}
@spec start_link(keyword()) :: GenServer.on_start()

start redis with nimble pool

examples

Examples

iex> LibRedis.Pool.start_link(pool: LibRedis.Pool.new())