mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 21:24:33 +08:00 
			
		
		
		
	缓存策略可以根据Key前缀进行批量删除
This commit is contained in:
		@@ -12,7 +12,7 @@ import (
 | 
				
			|||||||
	"github.com/iwind/TeaGo/types"
 | 
						"github.com/iwind/TeaGo/types"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
	strings "strings"
 | 
						"strings"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type PurgeAction struct {
 | 
					type PurgeAction struct {
 | 
				
			||||||
@@ -53,6 +53,7 @@ func (this *PurgeAction) RunGet(params struct {
 | 
				
			|||||||
func (this *PurgeAction) RunPost(params struct {
 | 
					func (this *PurgeAction) RunPost(params struct {
 | 
				
			||||||
	CachePolicyId int64
 | 
						CachePolicyId int64
 | 
				
			||||||
	ClusterId     int64
 | 
						ClusterId     int64
 | 
				
			||||||
 | 
						Type          string
 | 
				
			||||||
	Keys          string
 | 
						Keys          string
 | 
				
			||||||
	Must          *actions.Must
 | 
						Must          *actions.Must
 | 
				
			||||||
}) {
 | 
					}) {
 | 
				
			||||||
@@ -96,6 +97,11 @@ func (this *PurgeAction) RunPost(params struct {
 | 
				
			|||||||
		CachePolicyJSON: cachePolicyJSON,
 | 
							CachePolicyJSON: cachePolicyJSON,
 | 
				
			||||||
		Keys:            realKeys,
 | 
							Keys:            realKeys,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if params.Type == "prefix" {
 | 
				
			||||||
 | 
							msg.Type = messageconfigs.PurgeCacheMessageTypeDir
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							msg.Type = messageconfigs.PurgeCacheMessageTypeFile
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	results, err := nodeutils.SendMessageToCluster(this.AdminContext(), params.ClusterId, messageconfigs.MessageCodePurgeCache, msg, 10)
 | 
						results, err := nodeutils.SendMessageToCluster(this.AdminContext(), params.ClusterId, messageconfigs.MessageCodePurgeCache, msg, 10)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		this.ErrorPage(err)
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,37 +1,47 @@
 | 
				
			|||||||
{$layout}
 | 
					{$layout}
 | 
				
			||||||
 | 
					{$template "policy_menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{$template "policy_menu"}
 | 
					<h3>选择集群</h3>
 | 
				
			||||||
 | 
					<select class="ui dropdown auto-width" v-model="clusterId">
 | 
				
			||||||
 | 
					    <option v-for="cluster in clusters" :value="cluster.id">{{cluster.name}}</option>
 | 
				
			||||||
 | 
					</select>
 | 
				
			||||||
 | 
					<div class="ui divider"></div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	<h3>选择集群</h3>
 | 
					<h3>批量删除</h3>
 | 
				
			||||||
	<select class="ui dropdown auto-width" v-model="clusterId">
 | 
					<p class="comment">可以批量删除一组Key。</p>
 | 
				
			||||||
		<option v-for="cluster in clusters" :value="cluster.id">{{cluster.name}}</option>
 | 
					<form method="post" class="ui form" data-tea-action="$" data-tea-before="before" data-tea-success="success" data-tea-fail="fail" data-tea-done="done">
 | 
				
			||||||
	</select>
 | 
					    <input type="hidden" name="cachePolicyId" :value="cachePolicyId"/>
 | 
				
			||||||
	<div class="ui divider"></div>
 | 
					    <input type="hidden" name="clusterId" :value="clusterId"/>
 | 
				
			||||||
 | 
					    <table class="ui table definition selectable">
 | 
				
			||||||
	<h3>批量删除</h3>
 | 
					        <tr>
 | 
				
			||||||
	<p class="comment">可以批量删除一组Key。</p>
 | 
					            <td class="title">操作类型</td>
 | 
				
			||||||
	<form method="post" class="ui form" data-tea-action="$" data-tea-before="before" data-tea-success="success" data-tea-fail="fail" data-tea-done="done">
 | 
					            <td>
 | 
				
			||||||
		<input type="hidden" name="cachePolicyId" :value="cachePolicyId"/>
 | 
					                <radio name="type" :v-value="'key'" v-model="type">根据Key</radio>  
 | 
				
			||||||
		<input type="hidden" name="clusterId" :value="clusterId"/>
 | 
					                <radio name="type" :v-value="'prefix'" v-model="type">根据前缀</radio>
 | 
				
			||||||
		<table class="ui table definition selectable">
 | 
					            </td>
 | 
				
			||||||
			<tr>
 | 
					        </tr>
 | 
				
			||||||
				<td>Key列表</td>
 | 
					        <tr>
 | 
				
			||||||
				<td>
 | 
					            <td>
 | 
				
			||||||
					<textarea name="keys" rows="10" ref="focus"></textarea>
 | 
					                <span v-if="type == 'key'">Key列表</span>
 | 
				
			||||||
					<p class="comment">每行一个Key。</p>
 | 
					                <span v-if="type == 'prefix'">Key前缀列表</span>
 | 
				
			||||||
				</td>
 | 
					            </td>
 | 
				
			||||||
			</tr>
 | 
					            <td>
 | 
				
			||||||
			<tr>
 | 
					                <textarea name="keys" rows="10" ref="focus"></textarea>
 | 
				
			||||||
				<td class="title">操作结果</td>
 | 
					                <p class="comment" v-if="type == 'key'">每行一个Key,比如是一个完整的URL<code-label>https://example.com/hello/world.html</code-label>。</p>
 | 
				
			||||||
				<td>
 | 
					                <p class="comment" v-if="type == 'prefix'">每行一个Key前缀,比如是一个URL前缀<code-label>https://example.com/hello/</code-label>。</p>
 | 
				
			||||||
					<div v-if="isRequesting">数据发送中...</div>
 | 
					            </td>
 | 
				
			||||||
					<span class="red" v-if="!isRequesting && !isOk && message.length > 0">失败:{{message}}</span>
 | 
					        </tr>
 | 
				
			||||||
					<div v-if="!isRequesting && isOk">
 | 
					        <tr>
 | 
				
			||||||
						<span v-if="results.length == 0" class="red">此集群下没有任何可用的节点。</span>
 | 
					            <td>操作结果</td>
 | 
				
			||||||
						<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>
 | 
					            <td>
 | 
				
			||||||
					</div>
 | 
					                <div v-if="isRequesting">数据发送中...</div>
 | 
				
			||||||
				</td>
 | 
					                <span class="red" v-if="!isRequesting && !isOk && message.length > 0">失败:{{message}}</span>
 | 
				
			||||||
			</tr>
 | 
					                <div v-if="!isRequesting && isOk">
 | 
				
			||||||
		</table>
 | 
					                    <span v-if="results.length == 0" class="red">此集群下没有任何可用的节点。</span>
 | 
				
			||||||
		<submit-btn v-if="!isRequesting">提交</submit-btn>
 | 
					                    <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>
 | 
				
			||||||
	</form>
 | 
					                </div>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					        </tr>
 | 
				
			||||||
 | 
					    </table>
 | 
				
			||||||
 | 
					    <submit-btn v-if="!isRequesting">提交</submit-btn>
 | 
				
			||||||
 | 
					</form>
 | 
				
			||||||
@@ -31,4 +31,9 @@ Tea.context(function () {
 | 
				
			|||||||
	this.done = function () {
 | 
						this.done = function () {
 | 
				
			||||||
		this.isRequesting = false
 | 
							this.isRequesting = false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
});
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 操作类型
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						this.type = "key" // key | prefix
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
		Reference in New Issue
	
	Block a user