Module: Oxblood::Commands::Server
- Included in:
- Oxblood::Commands
- Defined in:
- lib/oxblood/commands/server.rb
Instance Method Summary collapse
-
#bgrewriteaof ⇒ String
Asynchronously rewrite the append-only file.
-
#bgsave ⇒ String
Asynchronously save the dataset to disk.
-
#client_getname ⇒ nil, String
Get the current conneciton name.
-
#client_kill(opts_or_addr = {}) ⇒ String, Integer
Kill the connection of a client.
-
#client_list ⇒ String
Get the list of client connections.
-
#client_pause(timeout) ⇒ String
Stop processing commands from clients for some time.
-
#client_setname(connection_name) ⇒ String
Set the current connection name.
-
#command ⇒ Array
Get array of Redis command details.
-
#command_count ⇒ Integer
Get total number of Redis commands.
-
#command_getkeys(*args) ⇒ Array
Extract keys given a full Redis command.
-
#command_info(*command_names) ⇒ Array
Get array of specific Redis command details.
-
#config_get(parameter) ⇒ Array
Get the value of a configuration parameter.
-
#config_resetstat ⇒ String
Reset the stats returned by INFO.
-
#config_rewrite ⇒ String
Rewrite the configuration file with the in memory configuration.
-
#config_set(parameter, value) ⇒ String
Set a configuration parameter to the given value.
-
#dbsize ⇒ Integer
Return the number of keys in the selected database.
-
#flushall(opts = {}) ⇒ String
Remove all keys from all databases.
-
#flushdb(opts = {}) ⇒ String
Remove all keys from the current database.
-
#info(section = nil) ⇒ String
Returns information and statistics about the server in a format that is simple to parse by computers and easy to read by humans.
-
#lastsave ⇒ Integer
Get the UNIX timestamp of the last successful save to disk.
-
#role ⇒ Array
Return the role of the instance in the context of replication.
-
#save ⇒ String
Synchronously save the dataset to disk.
-
#shutdown(opts = {}) ⇒ RError?
Synchronously save the dataset to disk and then shutdown the server.
-
#slaveof(host, port) ⇒ String
Make the server a slave of another instance, or promote it as master.
-
#slowlog(subcommand, argument = nil) ⇒ Integer, ...
Manages the Redis slow queries log.
-
#time ⇒ Array<String, String>
Returns the current server time.
Instance Method Details
#bgrewriteaof ⇒ String
Asynchronously rewrite the append-only file.
8 9 10 |
# File 'lib/oxblood/commands/server.rb', line 8 def bgrewriteaof run(:BGREWRITEAOF) end |
#bgsave ⇒ String
Asynchronously save the dataset to disk
16 17 18 |
# File 'lib/oxblood/commands/server.rb', line 16 def bgsave run(:BGSAVE) end |
#client_getname ⇒ nil, String
Get the current conneciton name.
24 25 26 |
# File 'lib/oxblood/commands/server.rb', line 24 def client_getname run(:CLIENT, :GETNAME) end |
#client_kill(opts_or_addr = {}) ⇒ String, Integer
Kill the connection of a client.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/oxblood/commands/server.rb', line 53 def client_kill(opts_or_addr = {}) if opts_or_addr.is_a?(String) run(:CLIENT, :KILL, opts_or_addr) else args = [:CLIENT, :KILL] if v = opts_or_addr[:id] args.push(:ID, v) end if v = opts_or_addr[:type] args.push(:TYPE, v) end if v = opts_or_addr[:addr] args.push(:ADDR, v) end if opts_or_addr.key?(:skipme) case opts_or_addr[:skipme] when false, 'no'.freeze args.push(:SKIPME, 'no'.freeze) when true, 'yes'.freeze args.push(:SKIPME, 'yes'.freeze) end end run(*args) end end |
#client_list ⇒ String
Get the list of client connections.
32 33 34 |
# File 'lib/oxblood/commands/server.rb', line 32 def client_list run(:CLIENT, :LIST) end |
#client_pause(timeout) ⇒ String
Stop processing commands from clients for some time.
100 101 102 |
# File 'lib/oxblood/commands/server.rb', line 100 def client_pause(timeout) run(:CLIENT, :PAUSE, timeout) end |
#client_setname(connection_name) ⇒ String
Set the current connection name.
90 91 92 |
# File 'lib/oxblood/commands/server.rb', line 90 def client_setname(connection_name) run(:CLIENT, :SETNAME, connection_name) end |
#command ⇒ Array
Get array of Redis command details.
108 109 110 |
# File 'lib/oxblood/commands/server.rb', line 108 def command run(:COMMAND) end |
#command_count ⇒ Integer
Get total number of Redis commands.
116 117 118 |
# File 'lib/oxblood/commands/server.rb', line 116 def command_count run(:COMMAND, :COUNT) end |
#command_getkeys(*args) ⇒ Array
Extract keys given a full Redis command
124 125 126 |
# File 'lib/oxblood/commands/server.rb', line 124 def command_getkeys(*args) run(*args.unshift(:COMMAND, :GETKEYS)) end |
#command_info(*command_names) ⇒ Array
Get array of specific Redis command details.
134 135 136 |
# File 'lib/oxblood/commands/server.rb', line 134 def command_info(*command_names) run(*command_names.unshift(:COMMAND, :INFO)) end |
#config_get(parameter) ⇒ Array
Get the value of a configuration parameter
144 145 146 |
# File 'lib/oxblood/commands/server.rb', line 144 def config_get(parameter) run(:CONFIG, :GET, parameter) end |
#config_resetstat ⇒ String
Reset the stats returned by INFO
171 172 173 |
# File 'lib/oxblood/commands/server.rb', line 171 def config_resetstat run(:CONFIG, :RESETSTAT) end |
#config_rewrite ⇒ String
Rewrite the configuration file with the in memory configuration
152 153 154 |
# File 'lib/oxblood/commands/server.rb', line 152 def config_rewrite run(:CONFIG, :REWRITE) end |
#config_set(parameter, value) ⇒ String
Set a configuration parameter to the given value
163 164 165 |
# File 'lib/oxblood/commands/server.rb', line 163 def config_set(parameter, value) run(:CONFIG, :SET, parameter, value) end |
#dbsize ⇒ Integer
Return the number of keys in the selected database
179 180 181 |
# File 'lib/oxblood/commands/server.rb', line 179 def dbsize run(:DBSIZE) end |
#flushall(opts = {}) ⇒ String
Remove all keys from all databases.
191 192 193 |
# File 'lib/oxblood/commands/server.rb', line 191 def flushall(opts = {}) opts[:async] ? run(:FLUSHALL, :ASYNC) : run(:FLUSHALL) end |
#flushdb(opts = {}) ⇒ String
Remove all keys from the current database.
203 204 205 |
# File 'lib/oxblood/commands/server.rb', line 203 def flushdb(opts = {}) opts[:async] ? run(:FLUSHDB, :ASYNC) : run(:FLUSHDB) end |
#info(section = nil) ⇒ String
Returns information and statistics about the server in a format that is simple to parse by computers and easy to read by humans.
214 215 216 |
# File 'lib/oxblood/commands/server.rb', line 214 def info(section = nil) section ? run(:INFO, section) : run(:INFO) end |
#lastsave ⇒ Integer
Get the UNIX timestamp of the last successful save to disk.
222 223 224 |
# File 'lib/oxblood/commands/server.rb', line 222 def lastsave run(:LASTSAVE) end |
#role ⇒ Array
Return the role of the instance in the context of replication.
232 233 234 |
# File 'lib/oxblood/commands/server.rb', line 232 def role run(:ROLE) end |
#save ⇒ String
Synchronously save the dataset to disk.
240 241 242 |
# File 'lib/oxblood/commands/server.rb', line 240 def save run(:SAVE) end |
#shutdown(opts = {}) ⇒ RError?
Synchronously save the dataset to disk and then shutdown the server.
254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/oxblood/commands/server.rb', line 254 def shutdown(opts = {}) case opts[:save] when nil run(:SHUTDOWN) when false run(:SHUTDOWN, :NOSAVE) else run(:SHUTDOWN, :SAVE) end rescue Errno::ECONNRESET nil end |
#slaveof(host, port) ⇒ String
Make the server a slave of another instance, or promote it as master.
279 280 281 |
# File 'lib/oxblood/commands/server.rb', line 279 def slaveof(host, port) run(:SLAVEOF, host, port) end |
#slowlog(subcommand, argument = nil) ⇒ Integer, ...
Manages the Redis slow queries log.
292 293 294 295 296 |
# File 'lib/oxblood/commands/server.rb', line 292 def slowlog(subcommand, argument = nil) args = [:SLOWLOG, subcommand] args << argument if argument run(*args) end |
#time ⇒ Array<String, String>
Returns the current server time.
302 303 304 |
# File 'lib/oxblood/commands/server.rb', line 302 def time run(:TIME) end |