From 73d049b3809a462b16f83650fce6e326b8875c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Thu, 16 Dec 2021 17:28:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0stale=20cache=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/serverconfigs/http_cache_config.go | 2 ++ pkg/serverconfigs/http_cache_stale_config.go | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 pkg/serverconfigs/http_cache_stale_config.go diff --git a/pkg/serverconfigs/http_cache_config.go b/pkg/serverconfigs/http_cache_config.go index 13bae02..4f761c4 100644 --- a/pkg/serverconfigs/http_cache_config.go +++ b/pkg/serverconfigs/http_cache_config.go @@ -16,6 +16,8 @@ type HTTPCacheConfig struct { PurgeIsOn bool `yaml:"purgeIsOn" json:"purgeIsOn"` // 是否允许使用Purge方法清理 PurgeKey string `yaml:"purgeKey" json:"purgeKey"` // Purge时使用的X-Edge-Purge-Key + Stale *HTTPCacheStaleConfig `yaml:"stale" json:"stale"` // 陈旧缓存使用策略 + CacheRefs []*HTTPCacheRef `yaml:"cacheRefs" json:"cacheRefs"` // 缓存配置 } diff --git a/pkg/serverconfigs/http_cache_stale_config.go b/pkg/serverconfigs/http_cache_stale_config.go new file mode 100644 index 0000000..504a32d --- /dev/null +++ b/pkg/serverconfigs/http_cache_stale_config.go @@ -0,0 +1,15 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package serverconfigs + +import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" + +// HTTPCacheStaleConfig Stale策略配置 +type HTTPCacheStaleConfig struct { + IsPrior bool `yaml:"isPrior" json:"isPrior"` + IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用 + + Status []int `yaml:"status" json:"status"` // 状态列表 + SupportStaleIfErrorHeader bool `yaml:"supportStaleIfErrorHeader" json:"supportStaleIfErrorHeader"` // 是否支持stale-if-error + Life *shared.TimeDuration `yaml:"life" json:"life"` // 陈旧内容生命周期 +}