Wrapper around the redis-cli binary for running commands against Redis instances.
Summary
Functions
Runs redis-cli --cluster create to form a cluster from the given node addresses.
Runs CLUSTER INFO and returns it as a parsed map.
Creates a new Cli struct.
Sends PING, returns true if PONG received.
Runs an arbitrary redis-cli command. Returns {:ok, output} or {:error, reason}.
Runs a command, raising on failure.
Runs SENTINEL MASTER <name> and returns parsed key-value map.
Sends SHUTDOWN NOSAVE. Best-effort, ignores errors.
Polls with PING until the server responds or timeout (ms) is reached.
Types
@type t() :: %RedisServerWrapper.Cli{ bin: String.t(), host: String.t(), password: String.t() | nil, port: non_neg_integer(), tls: boolean() }
Functions
@spec cluster_create(t(), [String.t()], non_neg_integer()) :: {:ok, String.t()} | {:error, String.t()}
Runs redis-cli --cluster create to form a cluster from the given node addresses.
Runs CLUSTER INFO and returns it as a parsed map.
Creates a new Cli struct.
Cli.new(port: 6400, password: "secret")
Sends PING, returns true if PONG received.
Runs an arbitrary redis-cli command. Returns {:ok, output} or {:error, reason}.
Runs a command, raising on failure.
Runs SENTINEL MASTER <name> and returns parsed key-value map.
@spec shutdown(t()) :: :ok
Sends SHUTDOWN NOSAVE. Best-effort, ignores errors.
@spec wait_for_ready(t(), non_neg_integer()) :: :ok | {:error, :timeout} | {:error, {:unexpected_reply, String.t()}}
Polls with PING until the server responds or timeout (ms) is reached.
Returns {:error, {:unexpected_reply, output}} if the peer accepts the
connection but responds with something other than PONG (or a transient
LOADING/BUSY reply). This catches the common case of another service
holding the port (e.g. macOS AirPlay on 7000) or a different redis-server
with a mismatched password already bound to the port.