mirror of https://github.com/tidwall/tile38.git
Fixed missing response in TTL json command
Using the tile38-cli, the TTL command omitted the ttl value from the json response. For example: 127.0.0.1:9851> TTL my ufo {"ok":true,"elapsed":"5.57µs"} Is now fixed to show 127.0.0.1:9851> TTL my ufo {"ok":true,"ttl":-1,"elapsed":"5.57µs"} Where "ttl" is the remaining time before the object is is deleted. The value -1 means that the object is available, but does not have an expiration. Thanks @phulst for finding this bug. closes #116
This commit is contained in:
parent
d3164f8bb9
commit
c02609ad44
|
@ -503,7 +503,7 @@ func (c *Controller) command(msg *server.Message, w io.Writer) (res string, d co
|
||||||
case "persist":
|
case "persist":
|
||||||
res, d, err = c.cmdPersist(msg)
|
res, d, err = c.cmdPersist(msg)
|
||||||
case "ttl":
|
case "ttl":
|
||||||
res, d, err = c.cmdTTL(msg)
|
res, err = c.cmdTTL(msg)
|
||||||
case "hooks":
|
case "hooks":
|
||||||
res, err = c.cmdHooks(msg)
|
res, err = c.cmdHooks(msg)
|
||||||
case "shutdown":
|
case "shutdown":
|
||||||
|
|
|
@ -940,7 +940,7 @@ func (c *Controller) cmdPersist(msg *server.Message) (res string, d commandDetai
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) cmdTTL(msg *server.Message) (res string, d commandDetailsT, err error) {
|
func (c *Controller) cmdTTL(msg *server.Message) (res string, err error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
vs := msg.Values[1:]
|
vs := msg.Values[1:]
|
||||||
var key, id string
|
var key, id string
|
||||||
|
@ -976,7 +976,17 @@ func (c *Controller) cmdTTL(msg *server.Message) (res string, d commandDetailsT,
|
||||||
}
|
}
|
||||||
switch msg.OutputType {
|
switch msg.OutputType {
|
||||||
case server.JSON:
|
case server.JSON:
|
||||||
res = `{"ok":true,"elapsed":"` + time.Now().Sub(start).String() + "\"}"
|
if ok {
|
||||||
|
var ttl string
|
||||||
|
if ok2 {
|
||||||
|
ttl = strconv.FormatFloat(v, 'f', -1, 64)
|
||||||
|
} else {
|
||||||
|
ttl = "-1"
|
||||||
|
}
|
||||||
|
res = `{"ok":true,"ttl":` + ttl + `,"elapsed":"` + time.Now().Sub(start).String() + "\"}"
|
||||||
|
} else {
|
||||||
|
return "", errIDNotFound
|
||||||
|
}
|
||||||
case server.RESP:
|
case server.RESP:
|
||||||
if ok {
|
if ok {
|
||||||
if ok2 {
|
if ok2 {
|
||||||
|
|
Loading…
Reference in New Issue