Added option to "not found" for DEL

This commit is contained in:
tidwall 2022-03-08 15:58:23 -07:00
parent 45fde6a430
commit 10f85640c0
3 changed files with 29 additions and 0 deletions

View File

@ -265,6 +265,12 @@
{
"name": "id",
"type": "string"
},
{
"command": "ERRON404",
"name": [],
"type": [],
"optional": true
}
],
"since": "1.0.0",

View File

@ -431,6 +431,12 @@ var commandsJSON = `{
{
"name": "id",
"type": "string"
},
{
"command": "ERRON404",
"name": [],
"type": [],
"optional": true
}
],
"since": "1.0.0",

View File

@ -290,6 +290,17 @@ func (s *Server) cmdDel(msg *Message) (res resp.Value, d commandDetails, err err
err = errInvalidNumberOfArguments
return
}
erron404 := false
if len(vs) > 0 {
_, arg, ok := tokenval(vs)
if ok && strings.ToLower(arg) == "erron404" {
erron404 = true
vs = vs[1:]
} else {
err = errInvalidArgument(arg)
return
}
}
if len(vs) != 0 {
err = errInvalidNumberOfArguments
return
@ -303,7 +314,13 @@ func (s *Server) cmdDel(msg *Message) (res resp.Value, d commandDetails, err err
s.deleteCol(d.key)
}
found = true
} else if erron404 {
err = errIDNotFound
return
}
} else if erron404 {
err = errKeyNotFound
return
}
s.groupDisconnectObject(d.key, d.id)
d.command = "del"