This commit is contained in:
xing 2022-09-19 22:20:10 +08:00
parent a8a0a1810f
commit aaa2b4baf3

2
cache/cache.go vendored
View File

@ -31,7 +31,7 @@ func (c *SliceCache[T]) FlushCache() {
func (c *SliceCache[T]) GetCache() []T { func (c *SliceCache[T]) GetCache() []T {
l := len(c.data) l := len(c.data)
expired := time.Duration(c.setTime.Unix())+c.expireTime/time.Second < time.Duration(time.Now().Unix()) expired := time.Duration(c.setTime.Unix())+c.expireTime/time.Second < time.Duration(time.Now().Unix())
if l < 1 || (l > 0 && c.expireTime > 0 && expired) { if l < 1 || (l > 0 && c.expireTime >= 0 && expired) {
r, err := c.setCacheFunc() r, err := c.setCacheFunc()
if err != nil { if err != nil {
log.Printf("set cache err[%s]", err) log.Printf("set cache err[%s]", err)