Skip to content

Commit

Permalink
fix(redis): redis ttl -1 and -2 (#3783)
Browse files Browse the repository at this point in the history
  • Loading branch information
1067088037 committed Dec 16, 2023
1 parent ebe0801 commit 4003864
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/stores/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,13 @@ func (s *Redis) TtlCtx(ctx context.Context, key string) (val int, err error) {
return err
}

val = int(duration / time.Second)
if duration >= 0 {
val = int(duration / time.Second)
} else {
// -2 means key does not exist
// -1 means key exists but has no expire
val = int(duration)
}
return nil
}, acceptable)

Expand Down

0 comments on commit 4003864

Please sign in to comment.