forked from mirror/ledisdb
add config rewrite command
This commit is contained in:
parent
c09c02c82b
commit
53f89f671b
|
@ -9,6 +9,7 @@ module.exports = [
|
|||
"flushall",
|
||||
"flushdb",
|
||||
"time",
|
||||
"config",
|
||||
|
||||
"bget",
|
||||
"bdelete",
|
||||
|
|
|
@ -154,6 +154,7 @@ local commands = {
|
|||
"flushall",
|
||||
"flushdb",
|
||||
"time",
|
||||
"config",
|
||||
|
||||
-- [[transaction]]
|
||||
"begin",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//This file was generated by .tools/generate_commands.py on Wed Oct 08 2014 13:52:31 +0800
|
||||
//This file was generated by .tools/generate_commands.py on Wed Oct 08 2014 16:36:20 +0800
|
||||
package main
|
||||
|
||||
var helpCommands = [][]string{
|
||||
|
@ -16,6 +16,7 @@ var helpCommands = [][]string{
|
|||
{"BTTL", "key", "Bitmap"},
|
||||
{"BXSCAN", "key [MATCH match] [COUNT count]", "Bitmap"},
|
||||
{"COMMIT", "-", "Transaction"},
|
||||
{"CONFIG REWRITE", "-", "Server"},
|
||||
{"DECR", "key", "KV"},
|
||||
{"DECRBY", "key decrement", "KV"},
|
||||
{"DEL", "key [key ...]", "KV"},
|
||||
|
|
|
@ -634,5 +634,11 @@
|
|||
"arguments" : "-",
|
||||
"group": "Server",
|
||||
"readonly": true
|
||||
},
|
||||
|
||||
"CONFIG REWRITE": {
|
||||
"arguments" : "-",
|
||||
"group": "Server",
|
||||
"readonly": false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,6 +133,7 @@ Table of Contents
|
|||
- [FLUSHDB](#flushdb)
|
||||
- [INFO [section]](#info-section)
|
||||
- [TIME](#time)
|
||||
- [CONFIG REWRITE](#config-rewrite)
|
||||
- [Transaction](#transaction)
|
||||
- [BEGIN](#begin)
|
||||
- [ROLLBACK](#rollback)
|
||||
|
@ -2579,6 +2580,16 @@ The TIME command returns the current server time as a two items lists: a Unix ti
|
|||
|
||||
array: two elements, one is unix time in seconds, the other is microseconds.
|
||||
|
||||
### CONFIG REWRITE
|
||||
|
||||
Rewrites the config file the server was started with.
|
||||
|
||||
**Unlike Redis rewrite, it will discard all comments in origin config file.**
|
||||
|
||||
**Return value**
|
||||
|
||||
String: OK or error msg.
|
||||
|
||||
## Transaction
|
||||
|
||||
### BEGIN
|
||||
|
|
|
@ -111,6 +111,24 @@ func timeCommand(c *client) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func configCommand(c *client) error {
|
||||
if len(c.args) < 1 {
|
||||
return ErrCmdParams
|
||||
}
|
||||
|
||||
switch strings.ToLower(hack.String(c.args[0])) {
|
||||
case "rewrite":
|
||||
if err := c.app.cfg.Rewrite(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
c.resp.writeStatus(OK)
|
||||
return nil
|
||||
}
|
||||
default:
|
||||
return ErrCmdParams
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
register("ping", pingCommand)
|
||||
register("echo", echoCommand)
|
||||
|
@ -119,4 +137,5 @@ func init() {
|
|||
register("flushall", flushallCommand)
|
||||
register("flushdb", flushdbCommand)
|
||||
register("time", timeCommand)
|
||||
register("config", configCommand)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue