Skip to content

Commit

Permalink
update(cache): modify handleUpdateRelease logic
Browse files Browse the repository at this point in the history
  • Loading branch information
skywli committed Nov 15, 2023
1 parent 1919084 commit 8094993
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cache/config/config_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import (

types "github.com/polarismesh/polaris/cache/api"
"github.com/polarismesh/polaris/common/eventhub"
"github.com/polarismesh/polaris/common/utils"
"github.com/polarismesh/polaris/common/model"
"github.com/polarismesh/polaris/common/utils"
"github.com/polarismesh/polaris/store"
)

Expand Down Expand Up @@ -204,10 +204,13 @@ func (fc *fileCache) sendEvent(item *model.ConfigFileRelease) {

// handleUpdateRelease
func (fc *fileCache) handleUpdateRelease(oldVal *model.SimpleConfigFileRelease, item *model.ConfigFileRelease) error {
// 如果有旧版本cache, 先删除再保存
if err := fc.handleDeleteRelease(oldVal); err != nil {
return err
// 如果ReleaseType类型变更, 先删除再保存
if oldVal != nil && oldVal.Typ != item.Typ {
if err := fc.handleDeleteRelease(oldVal); err != nil {
return err
}
}

fc.releases.Put(item.Id, item.SimpleConfigFileRelease)
func() {
// 记录 namespace -> group -> file_name -> []SimpleRelease 信息
Expand Down Expand Up @@ -413,7 +416,7 @@ func (fc *fileCache) GetActiveRelease(namespace, group, fileName string, typ mod
Namespace: namespace,
Group: group,
FileName: fileName,
Typ: typ,
Typ: typ,
}
simple, ok := groupBucket.Load(searchKey.ActiveKey())
if !ok {
Expand Down

0 comments on commit 8094993

Please sign in to comment.