Kombu.Transport.Redis.PrefixedClient (Kombu v0.1.0)

Copy Markdown View Source

Redis client wrapper (kombu.transport.redis.PrefixedStrictRedis & PrefixedRedisPubSub) that transparently applies global_keyprefix to keys, pipelines, Lua script keys, BRPOP keys, and Pub/Sub patterns/channels.

Summary

Functions

Executes a single Redis command through the underlying backend.

Executes a single Redis command, raising on error.

Creates a new %PrefixedClient{} wrapping conn (a Redix pid/name or {mod, ref} tuple).

Executes a pipeline of Redis commands through the underlying backend.

Executes a pipeline of Redis commands, raising on error.

Applies global_keyprefix to a Redis command list.

Prefixes key with global_keyprefix if non-empty.

Subscribes subscriber_pid to pattern(s) via Pub/Sub, applying global_keyprefix.

Unsubscribes subscriber_pid from pattern(s) via Pub/Sub, applying global_keyprefix.

Strips global_keyprefix from the beginning of key if present.

Types

backend()

@type backend() :: pid() | atom() | {module(), term()}

t()

@type t() :: %Kombu.Transport.Redis.PrefixedClient{
  conn: backend(),
  global_keyprefix: String.t(),
  pubsub: backend() | nil
}

Functions

command(client, cmd, opts \\ [])

@spec command(t(), [term()], keyword()) :: {:ok, term()} | {:error, term()}

Executes a single Redis command through the underlying backend.

command!(client, cmd, opts \\ [])

@spec command!(t(), [term()], keyword()) :: term()

Executes a single Redis command, raising on error.

new(conn, opts \\ [])

@spec new(backend(), keyword()) :: t()

Creates a new %PrefixedClient{} wrapping conn (a Redix pid/name or {mod, ref} tuple).

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

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

Executes a pipeline of Redis commands through the underlying backend.

pipeline!(client, commands, opts \\ [])

@spec pipeline!(t(), [[term()]], keyword()) :: [term()]

Executes a pipeline of Redis commands, raising on error.

prefix_command(prefix, command)

@spec prefix_command(t() | String.t(), [term()]) :: [term()]

Applies global_keyprefix to a Redis command list.

prefix_key(prefix, key)

@spec prefix_key(t() | String.t(), String.t()) :: String.t()

Prefixes key with global_keyprefix if non-empty.

psubscribe(client, patterns, subscriber_pid \\ self())

@spec psubscribe(t(), String.t() | [String.t()], pid()) ::
  {:ok, reference()} | {:error, term()}

Subscribes subscriber_pid to pattern(s) via Pub/Sub, applying global_keyprefix.

punsubscribe(client, patterns, subscriber_pid \\ self())

@spec punsubscribe(t(), String.t() | [String.t()], pid()) :: :ok | {:error, term()}

Unsubscribes subscriber_pid from pattern(s) via Pub/Sub, applying global_keyprefix.

unprefix_key(prefix, key)

@spec unprefix_key(t() | String.t(), String.t()) :: String.t()

Strips global_keyprefix from the beginning of key if present.