Skip to content

Commit 4003864

Browse files
authored
fix(redis): redis ttl -1 and -2 (#3783)
1 parent ebe0801 commit 4003864

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/stores/redis/redis.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,13 @@ func (s *Redis) TtlCtx(ctx context.Context, key string) (val int, err error) {
19931993
return err
19941994
}
19951995

1996-
val = int(duration / time.Second)
1996+
if duration >= 0 {
1997+
val = int(duration / time.Second)
1998+
} else {
1999+
// -2 means key does not exist
2000+
// -1 means key exists but has no expire
2001+
val = int(duration)
2002+
}
19972003
return nil
19982004
}, acceptable)
19992005

0 commit comments

Comments
 (0)