From 66c2a28e667b66b0d0e41d8b1403e8b4bb32d724 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Mon, 12 Sep 2022 19:29:43 +0800 Subject: [PATCH] fix #2364 (#2377) --- core/stores/cache/cachenode.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/stores/cache/cachenode.go b/core/stores/cache/cachenode.go index 69b5bf3d..1baae63b 100644 --- a/core/stores/cache/cachenode.go +++ b/core/stores/cache/cachenode.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "math" "math/rand" "sync" "time" @@ -130,7 +131,7 @@ func (c cacheNode) SetWithExpireCtx(ctx context.Context, key string, val interfa return err } - return c.rds.SetexCtx(ctx, key, string(data), int(expire.Seconds())) + return c.rds.SetexCtx(ctx, key, string(data), int(math.Ceil(expire.Seconds()))) } // String returns a string that represents the cacheNode. @@ -275,5 +276,6 @@ func (c cacheNode) processCache(ctx context.Context, key, data string, v interfa } func (c cacheNode) setCacheWithNotFound(ctx context.Context, key string) error { - return c.rds.SetexCtx(ctx, key, notFoundPlaceholder, int(c.aroundDuration(c.notFoundExpiry).Seconds())) + seconds := int(math.Ceil(c.aroundDuration(c.notFoundExpiry).Seconds())) + return c.rds.SetexCtx(ctx, key, notFoundPlaceholder, seconds) }