forked from mirror/redis
Fix "invalid expire time in set" for SetXX with expiration = 0
This commit is contained in:
parent
6f8957c5b7
commit
50f1aff778
10
commands.go
10
commands.go
|
@ -788,10 +788,14 @@ func (c *cmdable) SetNX(key string, value interface{}, expiration time.Duration)
|
||||||
// Zero expiration means the key has no expiration time.
|
// Zero expiration means the key has no expiration time.
|
||||||
func (c *cmdable) SetXX(key string, value interface{}, expiration time.Duration) *BoolCmd {
|
func (c *cmdable) SetXX(key string, value interface{}, expiration time.Duration) *BoolCmd {
|
||||||
var cmd *BoolCmd
|
var cmd *BoolCmd
|
||||||
if usePrecise(expiration) {
|
if expiration == 0 {
|
||||||
cmd = NewBoolCmd("set", key, value, "px", formatMs(expiration), "xx")
|
cmd = NewBoolCmd("set", key, value, "xx")
|
||||||
} else {
|
} else {
|
||||||
cmd = NewBoolCmd("set", key, value, "ex", formatSec(expiration), "xx")
|
if usePrecise(expiration) {
|
||||||
|
cmd = NewBoolCmd("set", key, value, "px", formatMs(expiration), "xx")
|
||||||
|
} else {
|
||||||
|
cmd = NewBoolCmd("set", key, value, "ex", formatSec(expiration), "xx")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.process(cmd)
|
c.process(cmd)
|
||||||
return cmd
|
return cmd
|
||||||
|
|
Loading…
Reference in New Issue