diff --git a/internal/web/actions/default/servers/components/cache/createPopup.go b/internal/web/actions/default/servers/components/cache/createPopup.go index 85c558e9..d451be55 100644 --- a/internal/web/actions/default/servers/components/cache/createPopup.go +++ b/internal/web/actions/default/servers/components/cache/createPopup.go @@ -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{ diff --git a/internal/web/actions/default/servers/components/cache/update.go b/internal/web/actions/default/servers/components/cache/update.go index 3c2e8e17..a9c049eb 100644 --- a/internal/web/actions/default/servers/components/cache/update.go +++ b/internal/web/actions/default/servers/components/cache/update.go @@ -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" ) @@ -52,7 +53,8 @@ func (this *UpdateAction) RunPost(params struct { Type string // file - FileDir string + FileDir string + FileMemoryCapacityJSON []byte CapacityJSON []byte MaxSizeJSON []byte @@ -74,8 +76,21 @@ func (this *UpdateAction) 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{ @@ -91,14 +106,14 @@ func (this *UpdateAction) RunPost(params struct { } _, err = this.RPC().HTTPCachePolicyRPC().UpdateHTTPCachePolicy(this.AdminContext(), &pb.UpdateHTTPCachePolicyRequest{ HttpCachePolicyId: params.CachePolicyId, - IsOn: params.IsOn, - Name: params.Name, - Description: params.Description, - CapacityJSON: params.CapacityJSON, - MaxKeys: params.MaxKeys, - MaxSizeJSON: params.MaxSizeJSON, - Type: params.Type, - OptionsJSON: optionsJSON, + IsOn: params.IsOn, + Name: params.Name, + Description: params.Description, + CapacityJSON: params.CapacityJSON, + MaxKeys: params.MaxKeys, + MaxSizeJSON: params.MaxSizeJSON, + Type: params.Type, + OptionsJSON: optionsJSON, }) if err != nil { this.ErrorPage(err) diff --git a/web/views/@default/servers/components/cache/createPopup.html b/web/views/@default/servers/components/cache/createPopup.html index 1618d04f..cbb470c3 100644 --- a/web/views/@default/servers/components/cache/createPopup.html +++ b/web/views/@default/servers/components/cache/createPopup.html @@ -25,16 +25,32 @@

存放文件缓存的目录,通常填写绝对路径。

+ + 文件目录最大容量 + + +

作为二级缓存的文件目录允许缓存的最大容量,如果为0表示没有限制。

+ + + + 内存最大容量 + + +

作为一级缓存的内存最大容量,如果为0表示不使用内存作为一级缓存。

+ + + + + 内存最大容量 + + +

允许缓存的最大容量,如果为0表示没有限制。

+ + + - - 缓存最大容量 - - -

允许缓存的最大内容长度,如果为0表示没有限制。

- - diff --git a/web/views/@default/servers/components/cache/policy.html b/web/views/@default/servers/components/cache/policy.html index 119ba1b1..5a99575b 100644 --- a/web/views/@default/servers/components/cache/policy.html +++ b/web/views/@default/servers/components/cache/policy.html @@ -19,49 +19,64 @@ - - 缓存目录 - - {{cachePolicy.options.dir}} -

存放文件缓存的目录,通常填写绝对路径。

- - + + 缓存目录 + + {{cachePolicy.options.dir}} +

存放文件缓存的目录,通常填写绝对路径。

+ + + + 文件目录最大容量 + + +

作为二级缓存的文件目录允许缓存的最大容量,如果为0表示没有限制。

+ + + + 内存最大容量 + + +

作为一级缓存的内存最大容量,如果为0表示不使用内存作为一级缓存。

+ + - - - 缓存最大容量 - - -

允许缓存的最大内容长度,如果为0表示没有限制。

- - + + + 缓存最大容量 + + +

允许缓存的最大容量,如果为0表示没有限制。

+ + + - - 最大内容长度 - - -

允许缓存的最大内容长度,如果为0表示没有限制。

- - - - 容纳Key数量 - - {{cachePolicy.maxKeys}} - 不限 -

可以容纳多少数量的Key,0表示不限制。

- - - - 描述 - - {{cachePolicy.description}} - 暂时还没有描述。 - - + + 最大内容长度 + + +

允许缓存的最大内容长度,如果为0表示没有限制。

+ + + + 容纳Key数量 + + {{cachePolicy.maxKeys}} + 不限 +

可以容纳多少数量的Key,0表示不限制。

+ + + + 描述 + + {{cachePolicy.description}} + 暂时还没有描述。 + + diff --git a/web/views/@default/servers/components/cache/update.html b/web/views/@default/servers/components/cache/update.html index dac4856c..054ba761 100644 --- a/web/views/@default/servers/components/cache/update.html +++ b/web/views/@default/servers/components/cache/update.html @@ -27,16 +27,38 @@

存放文件缓存的目录,通常填写绝对路径。

+ + 文件目录最大容量 + + +

作为二级缓存的文件目录允许缓存的最大容量,如果为0表示没有限制。

+ + + + 内存最大容量 + + +

作为一级缓存的内存最大容量,如果为0表示不使用内存作为一级缓存。

+ + + + 内存最大容量 + + +

作为一级缓存的内存最大容量,如果为0表示不使用内存作为一级缓存。

+ + - - - 缓存最大容量 - - -

允许缓存的最大内容长度,如果为0表示没有限制。

- - + + + 缓存最大容量 + + +

允许缓存的最大容量,如果为0表示没有限制。

+ + +