mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2026-04-08 00:15:19 +08:00
边缘节点支持设置多个缓存目录
This commit is contained in:
@@ -82,7 +82,7 @@ func (this *HTTPCachePolicy) IsSame(anotherPolicy *HTTPCachePolicy) bool {
|
||||
}
|
||||
|
||||
// UpdateDiskDir 修改文件路径
|
||||
func (this *HTTPCachePolicy) UpdateDiskDir(dir string) {
|
||||
func (this *HTTPCachePolicy) UpdateDiskDir(dir string, subDirs []*CacheDir) {
|
||||
if this.Type == CachePolicyStorageFile {
|
||||
oldOptionsJSON, err := json.Marshal(this.Options)
|
||||
if err != nil {
|
||||
@@ -95,20 +95,19 @@ func (this *HTTPCachePolicy) UpdateDiskDir(dir string) {
|
||||
return
|
||||
}
|
||||
|
||||
if options.Dir != dir {
|
||||
options.Dir = dir
|
||||
options.Dir = dir
|
||||
options.SubDirs = subDirs
|
||||
|
||||
newOptionsJSON, err := json.Marshal(options)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var newOptionsMap = map[string]interface{}{}
|
||||
err = json.Unmarshal(newOptionsJSON, &newOptionsMap)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
this.Options = newOptionsMap
|
||||
newOptionsJSON, err := json.Marshal(options)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var newOptionsMap = map[string]any{}
|
||||
err = json.Unmarshal(newOptionsJSON, &newOptionsMap)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
this.Options = newOptionsMap
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
package serverconfigs
|
||||
|
||||
import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
|
||||
type CacheDir struct {
|
||||
Path string `yaml:"path" json:"path"` // 目录
|
||||
Capacity *shared.SizeCapacity `yaml:"capacity" json:"capacity"` // 容量限制 TODO 暂时不实现
|
||||
}
|
||||
|
||||
// HTTPFileCacheStorage 文件缓存存储策略
|
||||
type HTTPFileCacheStorage struct {
|
||||
Dir string `yaml:"dir" json:"dir"` // 目录
|
||||
SubDirs []*CacheDir `yaml:"cacheDir" json:"subDirs"` // 子目录
|
||||
MemoryPolicy *HTTPCachePolicy `yaml:"memoryPolicy" json:"memoryPolicy"` // 内存二级缓存
|
||||
|
||||
OpenFileCache *OpenFileCacheConfig `yaml:"openFileCache" json:"openFileCache"` // open file cache配置
|
||||
|
||||
Reference in New Issue
Block a user