Skip to content

Latest commit

 

History

History
259 lines (151 loc) · 7.23 KB

eredis.md

File metadata and controls

259 lines (151 loc) · 7.23 KB

Module eredis

.

Description

Erlang Redis client

Usage:


 {ok, Client} = eredis:start_link().
 {ok, <<"OK">>} = eredis:q(Client, ["SET", "foo", "bar"]).
 {ok, <<"bar">>} = eredis:q(Client, ["GET", "foo"]).

Data Types


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()]

Function Index

q/2Equivalent to q(Client, Command, 5000).
q/3 Executes the given command in the specified connection.
q_noreply/2Executes the command but does not wait for a response and ignores any errors.
qp/2Equivalent to qp(Client, Pipeline, 5000).
qp/3 Executes the given pipeline (list of commands) in the specified connection.
start_link/0Equivalent to start_link("127.0.0.1", 6379, 0, "").
start_link/1 Start a Redis client.
start_link/2Equivalent to start_link(Host, Port, 0, "").
start_link/3Equivalent to start_link(Host, Port, Database, "").
start_link/4Equivalent to start_link(Host, Port, Database, Password, 100).
start_link/5Equivalent to start_link(Host, Port, Database, Password, ReconnectSleep, 5000).
start_link/6 Start a Redis client.
stop/1 Stop the Redis client.

Function Details

q/2


q(Client::client(), Command::[any()]) -> {ok, return_value()} | {error, Reason::binary() | no_connection}

Equivalent to q(Client, Command, 5000).

q/3


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/2


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/2


qp(Client::client(), Pipeline::pipeline()) -> [{ok, return_value()} | {error, Reason::binary()}] | {error, no_connection}

Equivalent to qp(Client, Pipeline, 5000).

qp/3


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/0


start_link() -> any()

Equivalent to start_link("127.0.0.1", 6379, 0, "").

start_link/1


start_link(Args::server_args()) -> {ok, Pid::pid()} | {error, Reason::term()}

Start a Redis client

start_link/2


start_link(Host::list(), Port::integer()) -> {ok, Pid::pid()} | {error, Reason::term()}

Equivalent to start_link(Host, Port, 0, "").

start_link/3


start_link(Host::list(), Port::integer(), Database::integer() | undefined) -> {ok, Pid::pid()} | {error, Reason::term()}

Equivalent to start_link(Host, Port, Database, "").

start_link/4


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/5


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/6


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/1


stop(Client::pid()) -> ok

Stop the Redis client.