View Source LibRedis.Pool (lib_redis v0.1.3)

LibRedis.Pool

Wrap redix with nimble_pool

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"]]}

Summary

Functions

delegate to Redix.command/2

create new redis pool instance

delegate to Redix.pipeline/2

start redis with nimble pool

Types

@type pool_opts_t() ::
  keyword(
    {:name, atom() | pid() | {atom(), atom(), term()}}
    | {:pool_size, non_neg_integer()}
    | {:url, binary()}
  )
@type t() :: %LibRedis.Pool{
  name: GenServer.name(),
  pool_size: non_neg_integer(),
  url: String.t()
}

Functions

Link to this function

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

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

delegate to Redix.command/2

Examples

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

create new redis pool instance

Options

  • :name - The name of the pool The default value is :redis_pool.

  • :pool_size (non_neg_integer/0) - The size of the pool The default value is 10.

  • :url (String.t/0) - Required. The url of the redis server, like redis://:123456@localhost:6379

Examples

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

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

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

delegate to Redix.pipeline/2

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

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