Command builders for Redis server administration and introspection.
Provides pure functions that build command lists for server-level operations
including connectivity checks (PING), server information (INFO, DBSIZE, TIME),
configuration management (CONFIG GET/SET), client management (CLIENT LIST/KILL),
persistence controls (SAVE, BGSAVE), and ACL management. Each function returns
a plain list of strings suitable for passing to Redis.command/2 or
Redis.pipeline/2.
These functions contain no connection or networking logic -- they only construct the Redis protocol command as a list.
Examples
Ping the server:
iex> Redis.Commands.Server.ping()
["PING"]
iex> Redis.Commands.Server.ping("hello")
["PING", "hello"]Retrieve a specific INFO section:
iex> Redis.Commands.Server.info("memory")
["INFO", "memory"]Read and update a configuration parameter:
iex> Redis.Commands.Server.config_get("maxmemory")
["CONFIG", "GET", "maxmemory"]
iex> Redis.Commands.Server.config_set("maxmemory", "256mb")
["CONFIG", "SET", "maxmemory", "256mb"]
Summary
Functions
Builds a CLIENT LIST command to retrieve information about connected clients.
Builds a CONFIG GET command to read a server configuration parameter.
Builds an INFO command to retrieve server information.
Builds a PING command, optionally with a custom message.
Deprecated: use replicaof/2 instead.
Functions
@spec acl_list() :: [String.t()]
@spec bgrewriteaof() :: [String.t()]
@spec client_getname() :: [String.t()]
@spec client_id() :: [String.t()]
@spec client_info() :: [String.t()]
Builds a CLIENT LIST command to retrieve information about connected clients.
Supports filtering by client type (:type) or specific client IDs (:id).
Examples
iex> Redis.Commands.Server.client_list()
["CLIENT", "LIST"]
iex> Redis.Commands.Server.client_list(type: "normal")
["CLIENT", "LIST", "TYPE", "normal"]
@spec command_count() :: [String.t()]
Builds a CONFIG GET command to read a server configuration parameter.
Supports glob-style patterns (e.g., "max*") to retrieve multiple parameters at once.
Example
iex> Redis.Commands.Server.config_get("maxmemory")
["CONFIG", "GET", "maxmemory"]
@spec config_resetstat() :: [String.t()]
@spec config_rewrite() :: [String.t()]
@spec dbsize() :: [String.t()]
Builds an INFO command to retrieve server information.
When called without arguments, returns all sections. Pass a section name (e.g., "memory", "replication", "stats") to limit the response.
Examples
iex> Redis.Commands.Server.info()
["INFO"]
iex> Redis.Commands.Server.info("replication")
["INFO", "replication"]
@spec lastsave() :: [String.t()]
@spec latency_latest() :: [String.t()]
@spec object_help() :: [String.t()]
Builds a PING command, optionally with a custom message.
When called without arguments, the server responds with "PONG". When called with a message, the server echoes that message back.
Examples
iex> Redis.Commands.Server.ping()
["PING"]
iex> Redis.Commands.Server.ping("hello")
["PING", "hello"]
@spec role() :: [String.t()]
@spec save() :: [String.t()]
Deprecated: use replicaof/2 instead.
@spec slowlog_len() :: [String.t()]
@spec slowlog_reset() :: [String.t()]
@spec time() :: [String.t()]