.
Erlang Redis client
Usage:
{ok, Client} = eredis:start_link().
{ok, <<"OK">>} = eredis:q(Client, ["SET", "foo", "bar"]).
{ok, <<"bar">>} = eredis:q(Client, ["GET", "foo"]).
client() = pid() | atom() | {atom(), atom()} | {global, term()} | {via, atom(), term()}
option() = {host, string()} | {port, integer()} | {database, string()} | {password, string()} | {reconnect_sleep, reconnect_sleep()} | {connect_timeout, integer()}
pipeline() = [iolist()]
reconnect_sleep() = no_reconnect | integer()
return_value() = undefined | binary() | [binary() | nonempty_list()]
server_args() = [option()]
q/2 | Equivalent to q(Client, Command, 5000). |
q/3 | Executes the given command in the specified connection. |
q_noreply/2 | Executes the command but does not wait for a response and ignores any errors. |
qp/2 | Equivalent to qp(Client, Pipeline, 5000). |
qp/3 | Executes the given pipeline (list of commands) in the specified connection. |
start_link/0 | Equivalent to start_link("127.0.0.1", 6379, 0, ""). |
start_link/1 | Start a Redis client. |
start_link/2 | Equivalent to start_link(Host, Port, 0, ""). |
start_link/3 | Equivalent to start_link(Host, Port, Database, ""). |
start_link/4 | Equivalent to start_link(Host, Port, Database, Password, 100). |
start_link/5 | Equivalent to start_link(Host, Port, Database, Password, ReconnectSleep, 5000). |
start_link/6 | Start a Redis client. |
stop/1 | Stop the Redis client. |
q(Client::client(), Command::[any()]) -> {ok, return_value()} | {error, Reason::binary() | no_connection}
Equivalent to q(Client, Command, 5000)
.
q(Client::client(), Command::[any()], Timeout::integer()) -> {ok, return_value()} | {error, Reason::binary() | no_connection}
Executes the given command in the specified connection. The command must be a valid Redis command and may contain arbitrary data which will be converted to binaries. The returned values will always be binaries.
q_noreply(Client::client(), Command::[any()]) -> ok
Executes the command but does not wait for a response and ignores any errors.
See also: q/2.
qp(Client::client(), Pipeline::pipeline()) -> [{ok, return_value()} | {error, Reason::binary()}] | {error, no_connection}
Equivalent to qp(Client, Pipeline, 5000)
.
qp(Client::client(), Pipeline::pipeline(), Timeout::integer()) -> [{ok, return_value()} | {error, Reason::binary()}] | {error, no_connection}
Executes the given pipeline (list of commands) in the specified connection. The commands must be valid Redis commands and may contain arbitrary data which will be converted to binaries. The values returned by each command in the pipeline are returned in a list.
start_link() -> any()
Equivalent to start_link("127.0.0.1", 6379, 0, "")
.
start_link(Args::server_args()) -> {ok, Pid::pid()} | {error, Reason::term()}
Start a Redis client
start_link(Host::list(), Port::integer()) -> {ok, Pid::pid()} | {error, Reason::term()}
Equivalent to start_link(Host, Port, 0, "")
.
start_link(Host::list(), Port::integer(), Database::integer() | undefined) -> {ok, Pid::pid()} | {error, Reason::term()}
Equivalent to start_link(Host, Port, Database, "")
.
start_link(Host::list(), Port::integer(), Database::integer() | undefined, Password::list()) -> {ok, Pid::pid()} | {error, Reason::term()}
Equivalent to start_link(Host, Port, Database, Password, 100)
.
start_link(Host::list(), Port::integer(), Database::integer() | undefined, Password::list(), ReconnectSleep::integer() | no_reconnect) -> {ok, Pid::pid()} | {error, Reason::term()}
Equivalent to start_link(Host, Port, Database, Password,ReconnectSleep, 5000)
.
start_link(Host::list(), Port::integer(), Database::integer() | undefined, Password::list(), ReconnectSleep::integer() | no_reconnect, ConnectTimeout::integer()) -> {ok, Pid::pid()} | {error, Reason::term()}
Start a Redis client
stop(Client::pid()) -> ok
Stop the Redis client.