mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
Merge pull request #1039 from go-redis/fix/ttl-1
Handle -1 in DurationCmd
This commit is contained in:
@ -439,7 +439,14 @@ func (cmd *DurationCmd) readReply(rd *proto.Reader) error {
|
||||
if cmd.err != nil {
|
||||
return cmd.err
|
||||
}
|
||||
cmd.val = time.Duration(n) * cmd.precision
|
||||
switch n {
|
||||
// -2 if the key does not exist
|
||||
// -1 if the key exists but has no associated expire
|
||||
case -2, -1:
|
||||
cmd.val = time.Duration(n)
|
||||
default:
|
||||
cmd.val = time.Duration(n) * cmd.precision
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user