缓存策略类型从“内存缓存”切换到“文件缓存“时增加默认设置

This commit is contained in:
刘祥超
2024-04-05 11:24:05 +08:00
parent fa94426133
commit 16f4fa6c3f
2 changed files with 17 additions and 1 deletions

View File

@@ -12,7 +12,7 @@
<tr>
<td class="color-border">缓存类型 *</td>
<td>
<select class="ui dropdown auto-width" name="type" v-model="policyType">
<select class="ui dropdown auto-width" name="type" v-model="policyType" @change="changePolicyType">
<option v-for="type in types" :value="type.type">{{type.name}}</option>
</select>
</td>

View File

@@ -7,4 +7,20 @@ Tea.context(function () {
if (this.cachePolicy.type == "file" && this.cachePolicy.options.openFileCache != null && this.cachePolicy.options.openFileCache.isOn && this.cachePolicy.options.openFileCache.max > 0) {
this.fileOpenFileCacheMax = this.cachePolicy.options.openFileCache.max
}
this.changePolicyType = function () {
if (this.policyType == "file") {
let options = this.cachePolicy.options
if (options != null && typeof options == "object" && typeof options["dir"] === "undefined") {
options["enableMMAP"] = true
options["dir"] = "/opt/cache"
options["memoryPolicy"] = {
capacity: {
unit: "gb",
count: 2
}
}
}
}
}
})