diff --git a/pkg/serverconfigs/health_check_config.go b/pkg/serverconfigs/health_check_config.go index dd4c579..07d1bec 100644 --- a/pkg/serverconfigs/health_check_config.go +++ b/pkg/serverconfigs/health_check_config.go @@ -5,7 +5,7 @@ import ( "github.com/iwind/TeaGo/maps" ) -// 健康检查设置 +// HealthCheckConfig 健康检查设置 type HealthCheckConfig struct { IsOn bool `yaml:"isOn" json:"isOn"` // 是否开启 URL string `yaml:"url" json:"url"` // 读取的URL @@ -21,7 +21,7 @@ type HealthCheckConfig struct { CountDown int `yaml:"countDown" json:"countDown"` // 连续离线认定次数 } -// 初始化 +// Init 初始化 func (this *HealthCheckConfig) Init() error { return nil } diff --git a/pkg/serverconfigs/http_cache_ref.go b/pkg/serverconfigs/http_cache_ref.go index aa8e94f..8d67ca8 100644 --- a/pkg/serverconfigs/http_cache_ref.go +++ b/pkg/serverconfigs/http_cache_ref.go @@ -15,7 +15,8 @@ type HTTPCacheRef struct { Key string `yaml:"key" json:"key"` // 每个缓存的Key规则,里面可以有变量 Life *shared.TimeDuration `yaml:"life" json:"life"` // 时间 Status []int `yaml:"status" json:"status"` // 缓存的状态码列表 - MaxSize *shared.SizeCapacity `yaml:"maxSize" json:"maxSize"` // 能够请求的最大尺寸 + MinSize *shared.SizeCapacity `yaml:"minSize" json:"minSize"` // 能够缓存的最小尺寸 + MaxSize *shared.SizeCapacity `yaml:"maxSize" json:"maxSize"` // 能够缓存的最大尺寸 SkipResponseCacheControlValues []string `yaml:"skipCacheControlValues" json:"skipCacheControlValues"` // 可以跳过的响应的Cache-Control值 SkipResponseSetCookie bool `yaml:"skipSetCookie" json:"skipSetCookie"` // 是否跳过响应的Set-Cookie Header @@ -29,11 +30,15 @@ type HTTPCacheRef struct { IsReverse bool `yaml:"isReverse" json:"isReverse"` // 是否为反向条件,反向条件的不缓存 lifeSeconds int64 + minSize int64 maxSize int64 uppercaseSkipCacheControlValues []string } func (this *HTTPCacheRef) Init() error { + if this.MinSize != nil { + this.minSize = this.MinSize.Bytes() + } if this.MaxSize != nil { this.maxSize = this.MaxSize.Bytes() } @@ -66,17 +71,22 @@ func (this *HTTPCacheRef) Init() error { return nil } -// 最大数据尺寸 +// MaxSizeBytes 最大数据尺寸 func (this *HTTPCacheRef) MaxSizeBytes() int64 { return this.maxSize } -// 生命周期 +// MinSizeBytes 最小数据尺寸 +func (this *HTTPCacheRef) MinSizeBytes() int64 { + return this.minSize +} + +// LifeSeconds 生命周期 func (this *HTTPCacheRef) LifeSeconds() int64 { return this.lifeSeconds } -// 是否包含某个Cache-Control值 +// ContainsCacheControl 是否包含某个Cache-Control值 func (this *HTTPCacheRef) ContainsCacheControl(value string) bool { return lists.ContainsString(this.uppercaseSkipCacheControlValues, strings.ToUpper(value)) }