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 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() { if server.config.maxMemory() > 0 && server.outOfMemory.on() {
err = errOOM err = errOOM
return return
@ -790,7 +790,9 @@ func (server *Server) cmdSet(msg *Message) (res resp.Value, d commandDetails, er
goto notok goto notok
} }
} }
if resetExpires {
server.clearIDExpires(d.key, d.id) server.clearIDExpires(d.key, d.id)
}
d.oldObj, d.oldFields, d.fields = col.Set(d.id, d.obj, fields, values) d.oldObj, d.oldFields, d.fields = col.Set(d.id, d.obj, fields, values)
d.command = "set" d.command = "set"
d.updated = true // perhaps we should do a diff on the previous object? 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 := *msg
nmsg.Args = []string{"SET", key, id, "OBJECT", json} nmsg.Args = []string{"SET", key, id, "OBJECT", json}
// SET key id OBJECT json // SET key id OBJECT json
return c.cmdSet(&nmsg) return c.cmdSet(&nmsg, false)
} }
if createcol { if createcol {
c.setCol(key, col) c.setCol(key, col)
@ -291,7 +291,7 @@ func (c *Server) cmdJdel(msg *Message) (res resp.Value, d commandDetails, err er
nmsg := *msg nmsg := *msg
nmsg.Args = []string{"SET", key, id, "OBJECT", json} nmsg.Args = []string{"SET", key, id, "OBJECT", json}
// SET key id OBJECT json // SET key id OBJECT json
return c.cmdSet(&nmsg) return c.cmdSet(&nmsg, false)
} }
d.key = key d.key = key

View File

@ -17,7 +17,7 @@ import (
"github.com/tidwall/geojson/geo" "github.com/tidwall/geojson/geo"
"github.com/tidwall/resp" "github.com/tidwall/resp"
"github.com/tidwall/tile38/internal/log" "github.com/tidwall/tile38/internal/log"
"github.com/yuin/gopher-lua" lua "github.com/yuin/gopher-lua"
luajson "layeh.com/gopher-json" luajson "layeh.com/gopher-json"
) )
@ -592,7 +592,7 @@ func (c *Server) commandInScript(msg *Message) (
default: default:
err = fmt.Errorf("unknown command '%s'", msg.Args[0]) err = fmt.Errorf("unknown command '%s'", msg.Args[0])
case "set": case "set":
res, d, err = c.cmdSet(msg) res, d, err = c.cmdSet(msg, true)
case "fset": case "fset":
res, d, err = c.cmdFset(msg) res, d, err = c.cmdFset(msg)
case "del": case "del":

View File

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