This commit is contained in:
bryanqiu 2023-04-13 11:39:26 +08:00
parent 3888bcb8cd
commit bea6d37069

View File

@ -166,7 +166,7 @@ func (c *localCacher[T]) GetFromCache(id string, options ...Option) (t *T, err e
if c.cacheDuration.Nanoseconds() > 0 {
var earliestCreateTime = time.Now().Add(-c.cacheDuration)
if a.CreateTime.Before(earliestCreateTime) {
log.Infof("cache(%s) is in redis cache but expired", id)
log.Infof("cache(%s) is in local cache but expired", id)
//TODO: cocurrent
delete(c.cacheItems, id)
return nil, ErrNotFound
@ -297,9 +297,9 @@ func (c *cacher[T]) GetFromCache(id string, options ...Option) (dat *T, err erro
// Step 3. get from [redis]
if c.redisCache != nil {
if opt.withCreateTime == nil { //get create time from redis
options = append(options, OptWithCreateTime, new(time.Time))
}
//if opt.withCreateTime == nil { //get create time from redis
// options = append(options, OptWithCreateTime, new(time.Time))
//}
if dat, err := c.redisCache.GetFromCache(id, options...); err == nil {
if c.localCache != nil {
c.localCache.SetIntoCache(id, dat, options...) //set create time from redis