缓存策略增加预热超时时间设置(默认20分钟)

This commit is contained in:
GoEdgeLab
2023-08-06 17:06:28 +08:00
parent 649de2ad60
commit 43f2f25646
6 changed files with 31 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ func (this *CreatePopupAction) Init() {
func (this *CreatePopupAction) RunGet(params struct{}) { func (this *CreatePopupAction) RunGet(params struct{}) {
this.Data["types"] = serverconfigs.AllCachePolicyStorageTypes this.Data["types"] = serverconfigs.AllCachePolicyStorageTypes
this.Show() this.Show()
} }
@@ -36,6 +37,7 @@ func (this *CreatePopupAction) RunPost(params struct {
CapacityJSON []byte CapacityJSON []byte
MaxSizeJSON []byte MaxSizeJSON []byte
FetchTimeoutJSON []byte
SyncCompressionCache bool SyncCompressionCache bool
Description string Description string
@@ -97,6 +99,7 @@ func (this *CreatePopupAction) RunPost(params struct {
Description: params.Description, Description: params.Description,
CapacityJSON: params.CapacityJSON, CapacityJSON: params.CapacityJSON,
MaxSizeJSON: params.MaxSizeJSON, MaxSizeJSON: params.MaxSizeJSON,
FetchTimeoutJSON: params.FetchTimeoutJSON,
Type: params.Type, Type: params.Type,
OptionsJSON: optionsJSON, OptionsJSON: optionsJSON,
SyncCompressionCache: params.SyncCompressionCache, SyncCompressionCache: params.SyncCompressionCache,

View File

@@ -26,6 +26,12 @@ func (this *PolicyAction) RunGet(params struct {
} }
this.Data["cachePolicy"] = cachePolicy this.Data["cachePolicy"] = cachePolicy
// 预热超时时间
this.Data["fetchTimeoutString"] = ""
if cachePolicy.FetchTimeout != nil && cachePolicy.FetchTimeout.Count > 0 {
this.Data["fetchTimeoutString"] = cachePolicy.FetchTimeout.Description()
}
this.Data["typeName"] = serverconfigs.FindCachePolicyStorageName(cachePolicy.Type) this.Data["typeName"] = serverconfigs.FindCachePolicyStorageName(cachePolicy.Type)
// 正在使用此策略的集群 // 正在使用此策略的集群
@@ -34,7 +40,7 @@ func (this *PolicyAction) RunGet(params struct {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
clusterMaps := []maps.Map{} var clusterMaps = []maps.Map{}
for _, cluster := range clustersResp.NodeClusters { for _, cluster := range clustersResp.NodeClusters {
clusterMaps = append(clusterMaps, maps.Map{ clusterMaps = append(clusterMaps, maps.Map{
"id": cluster.Id, "id": cluster.Id,

View File

@@ -61,6 +61,7 @@ func (this *UpdateAction) RunPost(params struct {
CapacityJSON []byte CapacityJSON []byte
MaxSizeJSON []byte MaxSizeJSON []byte
SyncCompressionCache bool SyncCompressionCache bool
FetchTimeoutJSON []byte
Description string Description string
IsOn bool IsOn bool
@@ -122,7 +123,7 @@ func (this *UpdateAction) RunPost(params struct {
} }
// 校验缓存条件 // 校验缓存条件
refs := []*serverconfigs.HTTPCacheRef{} var refs = []*serverconfigs.HTTPCacheRef{}
if len(params.RefsJSON) > 0 { if len(params.RefsJSON) > 0 {
err = json.Unmarshal(params.RefsJSON, &refs) err = json.Unmarshal(params.RefsJSON, &refs)
if err != nil { if err != nil {
@@ -146,6 +147,7 @@ func (this *UpdateAction) RunPost(params struct {
Type: params.Type, Type: params.Type,
OptionsJSON: optionsJSON, OptionsJSON: optionsJSON,
SyncCompressionCache: params.SyncCompressionCache, SyncCompressionCache: params.SyncCompressionCache,
FetchTimeoutJSON: params.FetchTimeoutJSON,
}) })
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)

View File

@@ -85,6 +85,13 @@
<checkbox name="syncCompressionCache"></checkbox> <checkbox name="syncCompressionCache"></checkbox>
<p class="comment">选中后在压缩设置开启的情况下在缓存源站内容的同时也会同步写入压缩缓存不选中表示在源站内容缓存后下一次调用才会缓存压缩内容防止同一时间内硬盘IO负载过高。</p> <p class="comment">选中后在压缩设置开启的情况下在缓存源站内容的同时也会同步写入压缩缓存不选中表示在源站内容缓存后下一次调用才会缓存压缩内容防止同一时间内硬盘IO负载过高。</p>
</td> </td>
</tr>
<tr>
<td>预热超时时间</td>
<td>
<time-duration-box :v-name="'fetchTimeoutJSON'" :v-unit="'minute'"></time-duration-box>
<p class="comment">预热读取源站的超时时间默认20分钟。</p>
</td>
</tr> </tr>
<tr> <tr>
<td>描述</td> <td>描述</td>

View File

@@ -83,6 +83,10 @@
<span v-else class="disabled">N</span> <span v-else class="disabled">N</span>
</td> </td>
</tr> </tr>
<tr>
<td>预热超时时间</td>
<td><span v-if="fetchTimeoutString.length > 0">{{fetchTimeoutString}}</span><span v-else class="disabled">使用默认</span></td>
</tr>
<tr> <tr>
<td>描述</td> <td>描述</td>
<td> <td>

View File

@@ -92,6 +92,13 @@
<checkbox name="syncCompressionCache" v-model="cachePolicy.syncCompressionCache"></checkbox> <checkbox name="syncCompressionCache" v-model="cachePolicy.syncCompressionCache"></checkbox>
<p class="comment">选中后在压缩设置开启的情况下在缓存源站内容的同时也会同步写入压缩缓存不选中表示在源站内容缓存后下一次调用才会缓存压缩内容防止同一时间内硬盘IO负载过高。</p> <p class="comment">选中后在压缩设置开启的情况下在缓存源站内容的同时也会同步写入压缩缓存不选中表示在源站内容缓存后下一次调用才会缓存压缩内容防止同一时间内硬盘IO负载过高。</p>
</td> </td>
</tr>
<tr>
<td>预热超时时间</td>
<td>
<time-duration-box :v-name="'fetchTimeoutJSON'" :v-value="cachePolicy.fetchTimeout"></time-duration-box>
<p class="comment">预热读取源站的超时时间默认20分钟。</p>
</td>
</tr> </tr>
<tr> <tr>
<td>描述</td> <td>描述</td>