🚀 feat(ratio-sync): major refactor & UX overhaul for Upstream Ratio Sync
This commit is contained in:
@@ -85,7 +85,11 @@ func UpdateCacheRatioByJSONString(jsonStr string) error {
|
||||
cacheRatioMapMutex.Lock()
|
||||
defer cacheRatioMapMutex.Unlock()
|
||||
cacheRatioMap = make(map[string]float64)
|
||||
return json.Unmarshal([]byte(jsonStr), &cacheRatioMap)
|
||||
err := json.Unmarshal([]byte(jsonStr), &cacheRatioMap)
|
||||
if err == nil {
|
||||
InvalidateExposedDataCache()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// GetCacheRatio returns the cache ratio for a model
|
||||
@@ -106,3 +110,13 @@ func GetCreateCacheRatio(name string) (float64, bool) {
|
||||
}
|
||||
return ratio, true
|
||||
}
|
||||
|
||||
func GetCacheRatioCopy() map[string]float64 {
|
||||
cacheRatioMapMutex.RLock()
|
||||
defer cacheRatioMapMutex.RUnlock()
|
||||
copyMap := make(map[string]float64, len(cacheRatioMap))
|
||||
for k, v := range cacheRatioMap {
|
||||
copyMap[k] = v
|
||||
}
|
||||
return copyMap
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user