mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-12 03:10:26 +08:00
实现open file cache
This commit is contained in:
@@ -31,6 +31,7 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
// file
|
||||
FileDir string
|
||||
FileMemoryCapacityJSON []byte
|
||||
FileOpenFileCacheMax int
|
||||
|
||||
CapacityJSON []byte
|
||||
MaxSizeJSON []byte
|
||||
@@ -62,15 +63,23 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
}
|
||||
}
|
||||
|
||||
var openFileCacheConfig *serverconfigs.OpenFileCacheConfig
|
||||
if params.FileOpenFileCacheMax > 0 {
|
||||
openFileCacheConfig = &serverconfigs.OpenFileCacheConfig{
|
||||
IsOn: true,
|
||||
Max: params.FileOpenFileCacheMax,
|
||||
}
|
||||
}
|
||||
|
||||
options = &serverconfigs.HTTPFileCacheStorage{
|
||||
Dir: params.FileDir,
|
||||
MemoryPolicy: &serverconfigs.HTTPCachePolicy{
|
||||
Capacity: memoryCapacity,
|
||||
},
|
||||
OpenFileCache: openFileCacheConfig,
|
||||
}
|
||||
case serverconfigs.CachePolicyStorageMemory:
|
||||
options = &serverconfigs.HTTPMemoryCacheStorage{
|
||||
}
|
||||
options = &serverconfigs.HTTPMemoryCacheStorage{}
|
||||
default:
|
||||
this.Fail("请选择正确的缓存类型")
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
// file
|
||||
FileDir string
|
||||
FileMemoryCapacityJSON []byte
|
||||
FileOpenFileCacheMax int
|
||||
|
||||
CapacityJSON []byte
|
||||
MaxSizeJSON []byte
|
||||
@@ -91,15 +92,23 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
}
|
||||
}
|
||||
|
||||
var openFileCacheConfig *serverconfigs.OpenFileCacheConfig
|
||||
if params.FileOpenFileCacheMax > 0 {
|
||||
openFileCacheConfig = &serverconfigs.OpenFileCacheConfig{
|
||||
IsOn: true,
|
||||
Max: params.FileOpenFileCacheMax,
|
||||
}
|
||||
}
|
||||
|
||||
options = &serverconfigs.HTTPFileCacheStorage{
|
||||
Dir: params.FileDir,
|
||||
MemoryPolicy: &serverconfigs.HTTPCachePolicy{
|
||||
Capacity: memoryCapacity,
|
||||
},
|
||||
OpenFileCache: openFileCacheConfig,
|
||||
}
|
||||
case serverconfigs.CachePolicyStorageMemory:
|
||||
options = &serverconfigs.HTTPMemoryCacheStorage{
|
||||
}
|
||||
options = &serverconfigs.HTTPMemoryCacheStorage{}
|
||||
default:
|
||||
this.Fail("请选择正确的缓存类型")
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="color-border">文件目录最大容量</td>
|
||||
<td class="color-border">文件目录最大容量 *</td>
|
||||
<td>
|
||||
<size-capacity-box :v-name="'capacityJSON'" :v-count="128" :v-unit="'gb'" :key="'capacityJSON1'"></size-capacity-box>
|
||||
<p class="comment">作为二级缓存的文件目录允许缓存的最大容量,如果为0表示没有限制。</p>
|
||||
@@ -38,6 +38,13 @@
|
||||
<size-capacity-box :v-name="'fileMemoryCapacityJSON'" :v-count="0" :v-unit="'gb'" :key="'fileMemoryCapacityJSON'"></size-capacity-box>
|
||||
<p class="comment">作为一级缓存的内存最大容量,如果为0表示不使用内存作为一级缓存。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="color-border">缓存文件句柄缓存</td>
|
||||
<td>
|
||||
<input type="text" name="fileOpenFileCacheMax" maxlength="6" value="0" style="width: 10em"/>
|
||||
<p class="comment">保持缓存文件句柄,提升缓存文件打开速度,建议数量是缓存文件数量的10%。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
|
||||
@@ -40,6 +40,10 @@
|
||||
<p class="comment">作为一级缓存的内存最大容量,如果为0表示不使用内存作为一级缓存。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="cachePolicy.options.openFileCache != null && cachePolicy.options.openFileCache.isOn && cachePolicy.options.openFileCache.max > 0">
|
||||
<td>缓存文件句柄缓存</td>
|
||||
<td>{{cachePolicy.options.openFileCache.max}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<tbody v-if="cachePolicy.type != 'file'">
|
||||
|
||||
@@ -47,6 +47,13 @@
|
||||
<size-capacity-box :v-name="'fileMemoryCapacityJSON'" :v-count="0" :v-unit="'gb'"></size-capacity-box>
|
||||
<p class="comment">作为一级缓存的内存最大容量,如果为0表示不使用内存作为一级缓存。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="color-border">缓存文件句柄缓存</td>
|
||||
<td>
|
||||
<input type="text" name="fileOpenFileCacheMax" v-model="fileOpenFileCacheMax" maxlength="6" value="0" style="width: 10em"/>
|
||||
<p class="comment">保持缓存文件句柄,提升缓存文件打开速度,建议数量是缓存文件数量的10%。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
|
||||
@@ -2,4 +2,9 @@ Tea.context(function () {
|
||||
this.success = NotifyReloadSuccess("保存成功 ")
|
||||
|
||||
this.policyType = this.cachePolicy.type
|
||||
|
||||
this.fileOpenFileCacheMax = 0
|
||||
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
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user