diff --git a/internal/server/crud.go b/internal/server/crud.go index 6c4aeca2..68d7aeb4 100644 --- a/internal/server/crud.go +++ b/internal/server/crud.go @@ -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? diff --git a/internal/server/json.go b/internal/server/json.go index 8706dbb8..762fcf1e 100644 --- a/internal/server/json.go +++ b/internal/server/json.go @@ -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 diff --git a/internal/server/scripts.go b/internal/server/scripts.go index 260baf42..4814e650 100644 --- a/internal/server/scripts.go +++ b/internal/server/scripts.go @@ -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() { diff --git a/internal/server/server.go b/internal/server/server.go index b933f1a8..54571898 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -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":