mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-03 00:38:40 +08:00
parent
9672071b5d
commit
66c2a28e66
6
core/stores/cache/cachenode.go
vendored
6
core/stores/cache/cachenode.go
vendored
@ -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…
Reference in New Issue
Block a user