mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-09 08:40:26 +08:00
文件缓存策略支持二级缓存(内存 | 文件)
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
@@ -28,7 +29,8 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
Type string
|
||||
|
||||
// file
|
||||
FileDir string
|
||||
FileDir string
|
||||
FileMemoryCapacityJSON []byte
|
||||
|
||||
CapacityJSON []byte
|
||||
MaxSizeJSON []byte
|
||||
@@ -50,8 +52,21 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
params.Must.
|
||||
Field("fileDir", params.FileDir).
|
||||
Require("请输入缓存目录")
|
||||
|
||||
memoryCapacity := &shared.SizeCapacity{}
|
||||
if len(params.FileMemoryCapacityJSON) > 0 {
|
||||
err := json.Unmarshal(params.FileMemoryCapacityJSON, memoryCapacity)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
options = &serverconfigs.HTTPFileCacheStorage{
|
||||
Dir: params.FileDir,
|
||||
MemoryPolicy: &serverconfigs.HTTPCachePolicy{
|
||||
Capacity: memoryCapacity,
|
||||
},
|
||||
}
|
||||
case serverconfigs.CachePolicyStorageMemory:
|
||||
options = &serverconfigs.HTTPMemoryCacheStorage{
|
||||
|
||||
Reference in New Issue
Block a user