Skip to content

Commit 0f7d505

Browse files
committed
优化缓存策略--“清理“功能
1 parent 43f2804 commit 0f7d505

File tree

7 files changed

+85
-31
lines changed

7 files changed

+85
-31
lines changed

web/views/@default/servers/components/cache/@policy_menu.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<menu-item :href="'/servers/components/cache/policy?cachePolicyId=' + cachePolicyId" code="index">{{cachePolicyName}}</menu-item>
55
<menu-item :href="'/servers/components/cache/test?cachePolicyId=' + cachePolicyId" code="test">测试</menu-item>
66
<menu-item :href="'/servers/components/cache/stat?cachePolicyId=' + cachePolicyId" code="stat">统计</menu-item>
7-
<!--<menu-item :href="'/servers/components/cache/clean?cachePolicyId=' + cachePolicyId" code="clean">清理</menu-item>-->
7+
<menu-item :href="'/servers/components/cache/clean?cachePolicyId=' + cachePolicyId" code="clean">清理</menu-item>
88
<menu-item :href="'/servers/components/cache/purge?cachePolicyId=' + cachePolicyId" code="purge">刷新</menu-item>
99
<menu-item :href="'/servers/components/cache/fetch?cachePolicyId=' + cachePolicyId" code="fetch">预热</menu-item>
1010
<menu-item :href="'/servers/components/cache/update?cachePolicyId=' + cachePolicyId" code="update">修改</menu-item>

web/views/@default/servers/components/cache/batch/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<td>
2424
<textarea name="keys" rows="20" ref="keysBox"></textarea>
2525
<p class="comment" v-if="keyType == 'key'">每行一个URL,比如<code-label>https://example.com/hello/world.html</code-label></p>
26-
<p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label></p>
26+
<p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label>;如果只填写域名部分,表示清理全站,比如<code-label>https://example.com/</code-label></p>
2727
</td>
2828
</tr>
2929
<tr>
Lines changed: 69 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,74 @@
11
{$layout}
22

3-
{$template "policy_menu"}
3+
{$template "policy_menu"}
44

5-
<h3>选择集群</h3>
6-
<select class="ui dropdown auto-width" v-model="clusterId">
7-
<option v-for="cluster in clusters" :value="cluster.id">{{cluster.name}}</option>
8-
</select>
9-
<div class="ui divider"></div>
5+
<h3>选择集群</h3>
6+
<select class="ui dropdown auto-width" v-model="clusterId">
7+
<option v-for="cluster in clusters" :value="cluster.id">{{cluster.name}}</option>
8+
</select>
9+
<div class="ui divider"></div>
1010

1111

12-
<h3>清理</h3>
13-
<p class=""><span class="red">严重注意:该操作将清理集群所有节点上的所有对应缓存。</span></p>
14-
<form method="post" data-tea-action="$" data-tea-before="before" data-tea-success="success" data-tea-fail="fail" data-tea-done="done" data-tea-timeout="300">
15-
<input type="hidden" name="cachePolicyId" :value="cachePolicyId"/>
16-
<input type="hidden" name="clusterId" :value="clusterId"/>
17-
<table class="ui table definition selectable">
18-
<tr>
19-
<td class="title">操作结果</td>
20-
<td>
21-
<div v-if="isRequesting">数据发送中...</div>
22-
<span class="red" v-if="!isRequesting && !isOk && message.length > 0">失败:{{message}}</span>
23-
<div v-if="!isRequesting && isOk">
24-
<span v-if="results.length == 0" class="red">此集群下没有任何可用的节点。</span>
25-
<div class="ui label tiny" v-for="one in results" :class="{green:one.isOk, red:!one.isOk}" style="margin-bottom: 0.5em">{{one.nodeName}}:{{one.message}}</div>
26-
</div>
27-
</td>
28-
</tr>
29-
</table>
30-
<submit-btn v-if="!isRequesting">提交</submit-btn>
31-
</form>
12+
<h3>清理</h3>
13+
<p class=""><span class="red">严重警告:该操作将清理集群所有节点上的所有当前策略产生的缓存;如果只是想清理单个缓存,请使用“刷新预热”功能。</span></p>
14+
<form method="post" data-tea-action="$" data-tea-before="before" data-tea-success="success" data-tea-fail="fail" data-tea-done="done" data-tea-timeout="300">
15+
<input type="hidden" name="cachePolicyId" :value="cachePolicyId"/>
16+
<input type="hidden" name="clusterId" :value="clusterId"/>
17+
<table class="ui table definition selectable">
18+
<tr>
19+
<td class="title">操作原因 *</td>
20+
<td>
21+
<p class="comment">为了防止新手滥用此功能、导致节点崩溃,你需要选择操作原因,才能继续操作:</p>
22+
<div>
23+
<radio v-model="reason" :v-value="REASON_NEW_PIE">我是一名新手,我不知道怎么清除缓存</radio>
24+
</div>
25+
<div style="margin-top: 0.6em">
26+
<radio v-model="reason" :v-value="REASON_BATCH_DELETE">要清理的域名太多,我比较懒,我不想用“刷新预热”功能</radio>
27+
</div>
28+
<div style="margin-top: 0.6em">
29+
<radio v-model="reason" :v-value="REASON_MAINTAINS">因节点磁盘空间不足或以往缓存设置错误或其他原因,想清除所有缓存,重新开始</radio>
30+
</div>
31+
<div style="margin-top: 0.6em">
32+
<radio v-model="reason" :v-value="REASON_ISSUE_REPORT">我怀疑“刷新预热”功能不起作用</radio>
33+
</div>
34+
</td>
35+
</tr>
36+
<tr v-show="!isReasonable()">
37+
<td>新手操作建议</td>
38+
<td>
39+
请使用左侧主菜单中的 <a href="/servers/components/cache/batch?keyType=prefix" target="_blank">[刷新预热]</a> 功能来清理你的缓存。
40+
</td>
41+
</tr>
42+
<tr v-show="reason == REASON_ISSUE_REPORT">
43+
<td>操作建议</td>
44+
<td>
45+
本产品提供的 <a href="/servers/components/cache/batch?keyType=prefix" target="_blank">[刷新预热]</a> 功能运行非常可靠,如果你确认发现功能异常,且能100%几率重现问题,请及时报告给软件开发者。
46+
</td>
47+
</tr>
48+
<tr v-show="reason == REASON_BATCH_DELETE">
49+
<td>操作建议</td>
50+
<td>
51+
请尽可能使用 <a href="/servers/components/cache/batch?keyType=prefix" target="_blank">[刷新预热]</a> 功能,避免影响当前系统上的别的网站。
52+
</td>
53+
</tr>
54+
<tr v-show="reason == REASON_MAINTAINS">
55+
<td>操作建议</td>
56+
<td>
57+
缓存文件较多时,系统需要消耗更多系统资源和更多时间删除缓存文件,磁盘使用空间会逐渐恢复,操作后,请耐心等待。
58+
</td>
59+
</tr>
60+
<tr v-show="isReasonable()">
61+
<td class="title">操作结果</td>
62+
<td>
63+
<div v-if="isRequesting">数据发送中...</div>
64+
<span class="red" v-if="!isRequesting && !isOk && message.length > 0">失败:{{message}}</span>
65+
<div v-if="!isRequesting && isOk">
66+
<span v-if="results.length == 0" class="red">此集群下没有任何可用的节点。</span>
67+
<div class="ui label tiny" v-for="one in results" :class="{green:one.isOk, red:!one.isOk}" style="margin-bottom: 0.5em">{{one.nodeName}}:{{one.message}}</div>
68+
</div>
69+
</td>
70+
</tr>
71+
</table>
72+
<submit-btn v-if="!isRequesting && isReasonable()">提交</submit-btn>
73+
<button class="ui button disabled" type="button" v-if="!isReasonable()">提交</button>
74+
</form>

web/views/@default/servers/components/cache/clean.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
Tea.context(function () {
2+
this.reason = 0
3+
4+
this.REASON_NEW_PIE = 0
5+
this.REASON_ISSUE_REPORT = 1
6+
this.REASON_BATCH_DELETE = 2
7+
this.REASON_MAINTAINS = 3
8+
9+
this.isReasonable = function () {
10+
return this.reason == this.REASON_ISSUE_REPORT || this.reason == this.REASON_BATCH_DELETE || this.reason == this.REASON_MAINTAINS
11+
}
12+
213
if (this.clusterId == null) {
314
if (this.clusters.length > 0) {
415
this.clusterId = this.clusters[0].id

web/views/@default/servers/components/cache/purge.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<td>
2121
<textarea name="keys" rows="10" ref="keysBox"></textarea>
2222
<p class="comment" v-if="keyType == 'key'">每行一个URL,比如<code-label>https://example.com/hello/world.html</code-label></p>
23-
<p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label></p>
23+
<p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label>;如果只填写域名部分,表示清理全站,比如<code-label>https://example.com/</code-label></p>
2424
</td>
2525
</tr>
2626
<tr>

web/views/@default/servers/groups/group/settings/cache/purge.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<td>
3131
<textarea name="keys" rows="10" ref="keysBox"></textarea>
3232
<p class="comment" v-if="keyType == 'key'">每行一个URL,比如<code-label>https://example.com/hello/world.html</code-label></p>
33-
<p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label></p>
33+
<p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label>;如果只填写域名部分,表示清理全站,比如<code-label>https://example.com/</code-label></p>
3434
</td>
3535
</tr>
3636
<tr>

web/views/@default/servers/server/settings/cache/purge.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<td>
3232
<textarea name="keys" rows="10" ref="keysBox"></textarea>
3333
<p class="comment" v-if="keyType == 'key'">每行一个URL,比如<code-label>https://example.com/hello/world.html</code-label></p>
34-
<p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label></p>
34+
<p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label>;如果只填写域名部分,表示清理全站,比如<code-label>https://example.com/</code-label></p>
3535
</td>
3636
</tr>
3737
<tr>

0 commit comments

Comments
 (0)