From 7b8e05b445883e589b5ad4c1c34569c99ebad569 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Wed, 12 Jan 2022 21:09:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0open=20file=20cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/serverconfigs/http_cache_storage_file.go | 10 +++++++++- pkg/serverconfigs/open_file_cache_config.go | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 pkg/serverconfigs/open_file_cache_config.go diff --git a/pkg/serverconfigs/http_cache_storage_file.go b/pkg/serverconfigs/http_cache_storage_file.go index 227eb0b..a43c11b 100644 --- a/pkg/serverconfigs/http_cache_storage_file.go +++ b/pkg/serverconfigs/http_cache_storage_file.go @@ -1,11 +1,19 @@ package serverconfigs -// 文件缓存存储策略 +// HTTPFileCacheStorage 文件缓存存储策略 type HTTPFileCacheStorage struct { Dir string `yaml:"dir" json:"dir"` // 目录 MemoryPolicy *HTTPCachePolicy `yaml:"memoryPolicy" json:"memoryPolicy"` // 内存二级缓存 + + OpenFileCache *OpenFileCacheConfig `yaml:"openFileCache" json:"openFileCache"` // open file cache配置 } func (this *HTTPFileCacheStorage) Init() error { + if this.OpenFileCache != nil { + err := this.OpenFileCache.Init() + if err != nil { + return err + } + } return nil } diff --git a/pkg/serverconfigs/open_file_cache_config.go b/pkg/serverconfigs/open_file_cache_config.go new file mode 100644 index 0000000..0544f93 --- /dev/null +++ b/pkg/serverconfigs/open_file_cache_config.go @@ -0,0 +1,15 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package serverconfigs + +const DefaultOpenFileCacheMax = 1024 + +// OpenFileCacheConfig open file cache配置 +type OpenFileCacheConfig struct { + IsOn bool `yaml:"isOn" json:"isOn"` + Max int `yaml:"max" json:"max"` +} + +func (this *OpenFileCacheConfig) Init() error { + return nil +}