View Source Module eredis
Data Types
client()
client() = pid() | atom() | {atom(), atom()} | {global, term()} | {via, atom(), term()}
host()
host() = string() | {local, string()}
obfuscated()
obfuscated() = fun(() -> iodata())
option()
option() = {host, string() | {local, string()}} | {port, inet:port_number()} | {database, integer()} | {username, iodata() | obfuscated() | undefined} | {password, iodata() | obfuscated() | undefined} | {reconnect_sleep, reconnect_sleep()} | {connect_timeout, integer()} | {socket_options, list()} | {tls, [ssl:tls_client_option()]} | {name, registered_name()} | {sentinel, list()}
options()
options() = [option()]
pipeline()
pipeline() = [iolist()]
reconnect_sleep()
reconnect_sleep() = no_reconnect | integer()
registered_name()
registered_name() = {local, atom()} | {global, term()} | {via, atom(), term()}
return_value()
return_value() = undefined | binary() | [binary() | nonempty_list()]
Function Index
q/2 | Executes the given command in the specified connection. |
q/3 | Like q/2 with a custom timeout. |
q_async/2 | Executes the command, and sends a message to the calling process with theresponse (with either error or success). |
q_async/3 | Executes the command, and sends a message to Pid with the response
(with either or success). |
q_noreply/2 | Executes the command but does not wait for a response and ignores any errors. |
qp/2 | Executes the given pipeline (list of commands) in the specified connection. |
qp/3 | Like qp/2 with a custom timeout. |
start_link/0 | Connect with default options. |
start_link/1 | Connect with the given options. |
start_link/2 | Connect to the given host and port. |
start_link/3 | (Deprecated.) |
start_link/4 | (Deprecated.) |
start_link/5 | (Deprecated.) |
start_link/6 | (Deprecated.) |
start_link/7 | (Deprecated.) |
stop/1 | Closes the connection and stops the client. |
Function Details
q/2
q(Client::client(), Command::[any()]) -> {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/3
q(Client::client(), Command::[any()], Timeout::timeout()) -> {ok, return_value()} | {error, Reason::binary() | no_connection}
Like q/2 with a custom timeout.
q_async/2
q_async(Client::client(), Command::[any()]) -> ok
Executes the command, and sends a message to the calling process with the
response (with either error or success). Message is of the form {response, Reply}
, where Reply
is the reply expected from q/2
.
q_async/3
q_async(Client::client(), Command::[any()], Pid::pid() | atom()) -> ok
Executes the command, and sends a message to Pid
with the response
(with either or success).
See also: q_async/2.
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}
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.
qp/3
qp(Client::client(), Pipeline::pipeline(), Timeout::timeout()) -> [{ok, return_value()} | {error, Reason::binary()}] | {error, no_connection}
Like qp/2 with a custom timeout.
start_link/0
start_link() -> {ok, Pid::pid()} | {error, Reason::term()}
Equivalent to start_link([])
.
Connect with default options.
start_link/1
start_link(Options::options()) -> {ok, pid()} | {error, Reason::term()}
Options
:
{host, Host}
{local, Path}
(available in OTP 19+); default "127.0.0.1"
{port, Port}
{database, Database}
{username, Username}
undefined
for no username; default undefined
{password, Password}
undefined
for no password; default undefined
{reconnect_sleep, ReconnectSleep}
{connect_timeout, Timeout}
{socket_options, SockOpts}
?SOCKET_OPTS
{tls, TlsOpts}
{name, Name}
{local, atom()}
; for all options see ServerName
atgen_server:start_link/4;
default: no name{sentinel, SentinelOptions}
{master_group, master_group_name}
- Atom, default: mymaster;{endpoints, [{Host, Port}]}
- List of {Host, Port} tuples, default: [{"127.0.0.1", 26379}];{username, Username}
;{password, Password}
;{connect_timeout, Timeout}
;{socket_options, SockOpts}
{tls, TlsOpts}
Connect with the given options.
start_link/2
start_link(Host::host(), Port::inet:port_number()) -> {ok, Pid::pid()} | {error, Reason::term()}
Equivalent to start_link([{host, Host}, {port, Port}])
.
Connect to the given host and port.
start_link/3
start_link(Host::host(), Port::inet:port_number(), OptionsOrDatabase) -> {ok, Pid::pid()} | {error, Reason::term()}
OptionsOrDatabase = options() | integer()
This function is deprecated: Use start_link/1
instead.
start_link/4
start_link(Host::host(), Port::inet:port_number(), Database::integer(), Password::string()) -> {ok, pid()} | {error, term()}
This function is deprecated: Use start_link/1
instead.
See also: start_link/1.
start_link/5
start_link(Host::host(), Port::inet:port_number(), Database::integer(), Password::string(), ReconnectSleep::reconnect_sleep()) -> {ok, pid()} | {error, term()}
This function is deprecated: Use start_link/1
instead.
See also: start_link/1.
start_link/6
start_link(Host::host(), Port::inet:port_number(), Database::integer(), Password::string(), ReconnectSleep::reconnect_sleep(), ConnectTimeout::timeout()) -> {ok, pid()} | {error, term()}
This function is deprecated: Use start_link/1
instead.
See also: start_link/1.
start_link/7
start_link(Host::host(), Port::inet:port_number(), Database::integer(), Password::string(), ReconnectSleep::reconnect_sleep(), ConnectTimeout::timeout(), SocketOptions::list()) -> {ok, pid()} | {error, term()}
This function is deprecated: Use start_link/1
instead.
See also: start_link/1.
stop/1
stop(Client::client()) -> ok
Closes the connection and stops the client.