Skip to content

Commit

Permalink
reset cache when get cache error (#575)
Browse files Browse the repository at this point in the history
Co-authored-by: miaodanyang
  • Loading branch information
miaow999 authored Jun 1, 2023
1 parent 5ec61cc commit 477888f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions plugin/cache/localcache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package localcache
import (
"github.com/VictoriaMetrics/fastcache"
"github.com/baetyl/baetyl-go/v2/errors"
"github.com/baetyl/baetyl-go/v2/log"

"github.com/baetyl/baetyl-cloud/v2/common"
"github.com/baetyl/baetyl-cloud/v2/plugin"
Expand All @@ -24,6 +25,7 @@ func New() (plugin.Plugin, error) {
return nil, errors.Trace(err)
}
cache := fastcache.New(cfg.FastCacheConfig.MaxBytes)
log.L().Info("cache set maxBytesSize", log.Any("size", cfg.FastCacheConfig.MaxBytes))
return &localFastCache{
c: cache,
}, nil
Expand Down
3 changes: 2 additions & 1 deletion service/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ func (n *NodeServiceImpl) GetAllShadowReportTime(namespace string, lenNode int)
if dataReportTime != nil {
err = json.Unmarshal(dataReportTime, &reportTimeMap)
if err != nil {
return nil, errors.Trace(err)
log.L().Error("decode report time error", log.Error(err))
return n.SetNodeShadowCache(namespace)
}
}
// check time cache len < lenNode
Expand Down

0 comments on commit 477888f

Please sign in to comment.