实现服务的缓存策略设置

This commit is contained in:
GoEdgeLab
2020-10-04 20:38:12 +08:00
parent 9f8c705d12
commit ae788f2e9f

View File

@@ -215,23 +215,23 @@ func (this *HTTPWebDAO) ComposeWebConfig(webId int64) (*serverconfigs.HTTPWebCon
// 缓存配置 // 缓存配置
if IsNotNull(web.Cache) { if IsNotNull(web.Cache) {
cacheRefs := []*serverconfigs.HTTPCacheRef{} cacheConfig := &serverconfigs.HTTPCacheConfig{}
err = json.Unmarshal([]byte(web.Cache), &cacheRefs) err = json.Unmarshal([]byte(web.Cache), &cacheConfig)
if err != nil { if err != nil {
return nil, err return nil, err
} }
for _, cacheRef := range cacheRefs { for _, cacheRef := range cacheConfig.CacheRefs {
if cacheRef.CachePolicyId > 0 { if cacheRef.CachePolicyId > 0 {
cachePolicy, err := SharedHTTPCachePolicyDAO.ComposeCachePolicy(cacheRef.CachePolicyId) cachePolicy, err := SharedHTTPCachePolicyDAO.ComposeCachePolicy(cacheRef.CachePolicyId)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if cachePolicy != nil { if cachePolicy != nil {
config.CacheRefs = append(config.CacheRefs, cacheRef) cacheRef.CachePolicy = cachePolicy
config.CachePolicies = append(config.CachePolicies, cachePolicy)
} }
} }
} }
config.Cache = cacheConfig
} }
// 防火墙配置 // 防火墙配置