Kevin Wan 2 years ago committed by GitHub
parent 9672071b5d
commit 66c2a28e66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"math"
"math/rand" "math/rand"
"sync" "sync"
"time" "time"
@ -130,7 +131,7 @@ func (c cacheNode) SetWithExpireCtx(ctx context.Context, key string, val interfa
return err 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. // 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 { 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)
} }

Loading…
Cancel
Save