mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 07:50:25 +08:00 
			
		
		
		
	优化节点配置生成速度
This commit is contained in:
		@@ -3,6 +3,7 @@ package models
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAPI/internal/utils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
 | 
			
		||||
@@ -75,12 +76,12 @@ func (this *HTTPWebDAO) FindEnabledHTTPWeb(tx *dbs.Tx, id int64) (*HTTPWeb, erro
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ComposeWebConfig 组合配置
 | 
			
		||||
func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap maps.Map) (*serverconfigs.HTTPWebConfig, error) {
 | 
			
		||||
func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap *utils.CacheMap) (*serverconfigs.HTTPWebConfig, error) {
 | 
			
		||||
	if cacheMap == nil {
 | 
			
		||||
		cacheMap = maps.Map{}
 | 
			
		||||
		cacheMap = utils.NewCacheMap()
 | 
			
		||||
	}
 | 
			
		||||
	var cacheKey = this.Table + ":config:" + types.String(webId)
 | 
			
		||||
	var cache = cacheMap.Get(cacheKey)
 | 
			
		||||
	var cache, _ = cacheMap.Get(cacheKey)
 | 
			
		||||
	if cache != nil {
 | 
			
		||||
		return cache.(*serverconfigs.HTTPWebConfig), nil
 | 
			
		||||
	}
 | 
			
		||||
@@ -418,7 +419,9 @@ func (this *HTTPWebDAO) ComposeWebConfig(tx *dbs.Tx, webId int64, cacheMap maps.
 | 
			
		||||
		config.RemoteAddr = remoteAddrConfig
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cacheMap[cacheKey] = config
 | 
			
		||||
	if cacheMap != nil {
 | 
			
		||||
		cacheMap.Put(cacheKey, config)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return config, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user