module Redis::Commands::Server
def bgrewriteaof
-
(String)
- `OK`
def bgrewriteaof send_command([:bgrewriteaof]) end
def bgsave
-
(String)
- `OK`
def bgsave send_command([:bgsave]) end
def client(subcommand, *args)
-
(String, Hash)
- depends on subcommand
Parameters:
-
subcommand
(String, Symbol
) -- e.g. `kill`, `list`, `getname`, `setname`
def client(subcommand, *args) send_command([:client, subcommand] + args) do |reply| if subcommand.to_s == "list" reply.lines.map do |line| entries = line.chomp.split(/[ =]/) Hash[entries.each_slice(2).to_a] end else reply end end end
def config(action, *args)
-
(String, Hash)
- string reply, or hash when retrieving more than one
Parameters:
-
action
(Symbol
) -- e.g. `:get`, `:set`, `:resetstat`
def config(action, *args) send_command([:config, action] + args) do |reply| if reply.is_a?(Array) && action == :get Hashify.call(reply) else reply end end end
def dbsize
-
(Integer)
-
def dbsize send_command([:dbsize]) end
def debug(*args)
def debug(*args) send_command([:debug] + args) end
def flushall(options = nil)
-
(String)
- `OK`
Parameters:
-
options
(Hash
) --
def flushall(options = nil) if options && options[:async] send_command(%i[flushall async]) else send_command([:flushall]) end end
def flushdb(options = nil)
-
(String)
- `OK`
Parameters:
-
options
(Hash
) --
def flushdb(options = nil) if options && options[:async] send_command(%i[flushdb async]) else send_command([:flushdb]) end end
def info(cmd = nil)
-
(Hash
-)
Parameters:
-
cmd
(String, Symbol
) -- e.g. "commandstats"
def info(cmd = nil) send_command([:info, cmd].compact) do |reply| if reply.is_a?(String) reply = HashifyInfo.call(reply) if cmd && cmd.to_s == "commandstats" # Extract nested hashes for INFO COMMANDSTATS reply = Hash[reply.map do |k, v| v = v.split(",").map { |e| e.split("=") } [k[/^cmdstat_(.*)$/, 1], Hash[v]] end] end end reply end end
def lastsave
-
(Integer)
-
def lastsave send_command([:lastsave]) end
def monitor
- Yieldparam: line - timestamp and command that was executed
Other tags:
- Yield: - a block to be called for every line of output
def monitor synchronize do |client| client = client.pubsub client.call_v([:monitor]) loop do yield client.next_event end end end
def save
-
(String)
-
def save send_command([:save]) end
def shutdown
def shutdown synchronize do |client| client.disable_reconnection do client.call_v([:shutdown]) rescue ConnectionError # This means Redis has probably exited. nil end end end
def slaveof(host, port)
def slaveof(host, port) send_command([:slaveof, host, port]) end
def slowlog(subcommand, length = nil)
-
(Array
- depends on subcommand, Integer, String)
Parameters:
-
length
(Integer
) -- maximum number of entries to return -
subcommand
(String
) -- e.g. `get`, `len`, `reset`
def slowlog(subcommand, length = nil) args = [:slowlog, subcommand] args << Integer(length) if length send_command(args) end
def sync
def sync send_command([:sync]) end
def time
-
(Array
- tuple of seconds since UNIX epoch and)
def time send_command([:time]) do |reply| reply&.map(&:to_i) end end