Fix JSET cancels expiry

issue #498
This commit is contained in:
tidwall 2019-10-08 09:45:46 -07:00
parent 13c206fe05
commit 87185319b2
4 changed files with 12 additions and 10 deletions

View File

@ -760,7 +760,7 @@ func (server *Server) parseSetArgs(vs []string) (
return
}
func (server *Server) cmdSet(msg *Message) (res resp.Value, d commandDetails, err error) {
func (server *Server) cmdSet(msg *Message, resetExpires bool) (res resp.Value, d commandDetails, err error) {
if server.config.maxMemory() > 0 && server.outOfMemory.on() {
err = errOOM
return
@ -790,7 +790,9 @@ func (server *Server) cmdSet(msg *Message) (res resp.Value, d commandDetails, er
goto notok
}
}
server.clearIDExpires(d.key, d.id)
if resetExpires {
server.clearIDExpires(d.key, d.id)
}
d.oldObj, d.oldFields, d.fields = col.Set(d.id, d.obj, fields, values)
d.command = "set"
d.updated = true // perhaps we should do a diff on the previous object?

View File

@ -222,7 +222,7 @@ func (c *Server) cmdJset(msg *Message) (res resp.Value, d commandDetails, err er
nmsg := *msg
nmsg.Args = []string{"SET", key, id, "OBJECT", json}
// SET key id OBJECT json
return c.cmdSet(&nmsg)
return c.cmdSet(&nmsg, false)
}
if createcol {
c.setCol(key, col)
@ -291,7 +291,7 @@ func (c *Server) cmdJdel(msg *Message) (res resp.Value, d commandDetails, err er
nmsg := *msg
nmsg.Args = []string{"SET", key, id, "OBJECT", json}
// SET key id OBJECT json
return c.cmdSet(&nmsg)
return c.cmdSet(&nmsg, false)
}
d.key = key

View File

@ -17,7 +17,7 @@ import (
"github.com/tidwall/geojson/geo"
"github.com/tidwall/resp"
"github.com/tidwall/tile38/internal/log"
"github.com/yuin/gopher-lua"
lua "github.com/yuin/gopher-lua"
luajson "layeh.com/gopher-json"
)
@ -161,7 +161,7 @@ func (pl *lStatePool) New() *lua.LState {
"error_reply": errorReply,
"status_reply": statusReply,
"sha1hex": sha1hex,
"distance_to": distanceTo,
"distance_to": distanceTo,
}
L.SetGlobal("tile38", L.SetFuncs(L.NewTable(), exports))
@ -592,7 +592,7 @@ func (c *Server) commandInScript(msg *Message) (
default:
err = fmt.Errorf("unknown command '%s'", msg.Args[0])
case "set":
res, d, err = c.cmdSet(msg)
res, d, err = c.cmdSet(msg, true)
case "fset":
res, d, err = c.cmdFset(msg)
case "del":
@ -707,7 +707,7 @@ func (c *Server) luaTile38AtomicRW(msg *Message) (resp.Value, error) {
if msg.Deadline != nil {
if write {
res = NOMessage
err = errTimeoutOnCmd(msg.Command())
err = errTimeoutOnCmd(msg.Command())
return
}
defer func() {
@ -813,7 +813,7 @@ func (c *Server) luaTile38NonAtomic(msg *Message) (resp.Value, error) {
if msg.Deadline != nil {
if write {
res = NOMessage
err = errTimeoutOnCmd(msg.Command())
err = errTimeoutOnCmd(msg.Command())
return
}
defer func() {

View File

@ -932,7 +932,7 @@ func (server *Server) command(msg *Message, client *Client) (
default:
err = fmt.Errorf("unknown command '%s'", msg.Args[0])
case "set":
res, d, err = server.cmdSet(msg)
res, d, err = server.cmdSet(msg, true)
case "fset":
res, d, err = server.cmdFset(msg)
case "del":