From 400386459cbf65a9fb7adaca9b4952caf1692ca9 Mon Sep 17 00:00:00 2001 From: Summer-lights <42484234+1067088037@users.noreply.github.com> Date: Sat, 16 Dec 2023 13:46:53 +0800 Subject: [PATCH] fix(redis): redis ttl -1 and -2 (#3783) --- core/stores/redis/redis.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/stores/redis/redis.go b/core/stores/redis/redis.go index c5549e3d..d8301a8c 100644 --- a/core/stores/redis/redis.go +++ b/core/stores/redis/redis.go @@ -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)