diff --git a/pkg/lru/lru.go b/pkg/lru/lru.go index 4dd6374..795c367 100644 --- a/pkg/lru/lru.go +++ b/pkg/lru/lru.go @@ -6,6 +6,8 @@ import ( "gitee.com/timedb/wheatCache/pkg/errorx" "gitee.com/timedb/wheatCache/pkg/event" "gitee.com/timedb/wheatCache/pkg/structure" + "gitee.com/timedb/wheatCache/pkg/util" + "github.com/spf13/viper" "sync/atomic" ) @@ -32,29 +34,29 @@ func (lru *SingleCache) UpdateLruSize(length structure.UpdateLength) { } func cacheInit() (int64, int64, int) { - //maxSize := viper.GetString("lruCache.maxSize") - //retMaxSize, maxErr := util.ParseSizeToBit(maxSize) - //if maxErr != nil { - // return 0, 0, 0 - //} - //if retMaxSize == 0 { - // retMaxSize = lruMaxSize - //} - // - //clearSize := viper.GetString("lruCache.clearSize") - //retClearSize, clearErr := util.ParseSizeToBit(clearSize) - //if clearErr != nil { - // return 0, 0, 0 - //} - //if retClearSize == 0 { - // retClearSize = lruClearSize - //} - // - //maxDriver := viper.GetInt("lruCache.eventDriverSize") - //if maxDriver == 0 { - // maxDriver = lruEventDriver - //} - return 30, 15, 2000 + maxSize := viper.GetString("lruCache.maxSize") + retMaxSize, maxErr := util.ParseSizeToBit(maxSize) + if maxErr != nil { + return 0, 0, 0 + } + if retMaxSize == 0 { + retMaxSize = lruMaxSize + } + + clearSize := viper.GetString("lruCache.clearSize") + retClearSize, clearErr := util.ParseSizeToBit(clearSize) + if clearErr != nil { + return 0, 0, 0 + } + if retClearSize == 0 { + retClearSize = lruClearSize + } + + maxDriver := viper.GetInt("lruCache.eventDriverSize") + if maxDriver == 0 { + maxDriver = lruEventDriver + } + return retMaxSize, retClearSize, maxDriver } // NewLRUCache lru初始化