缓存支持请求方法设置

This commit is contained in:
GoEdgeLab
2021-12-07 10:43:42 +08:00
parent 46d979e695
commit 928bbae0c8
2 changed files with 7 additions and 0 deletions

View File

@@ -110,6 +110,7 @@ func (this *HTTPRequest) init() {
// 缓存相关初始化 // 缓存相关初始化
"cache.status": "BYPASS", "cache.status": "BYPASS",
"cache.age": "0", "cache.age": "0",
"cache.key": "",
"cache.policy.name": "", "cache.policy.name": "",
"cache.policy.id": "0", "cache.policy.id": "0",
"cache.policy.type": "", "cache.policy.type": "",

View File

@@ -81,6 +81,12 @@ func (this *HTTPRequest) doCacheRead() (shouldStop bool) {
} }
} }
// 校验请求
if !this.cacheRef.MatchRequest(this.RawReq) {
this.cacheRef = nil
return
}
// 相关变量 // 相关变量
this.varMapping["cache.policy.name"] = cachePolicy.Name this.varMapping["cache.policy.name"] = cachePolicy.Name
this.varMapping["cache.policy.id"] = strconv.FormatInt(cachePolicy.Id, 10) this.varMapping["cache.policy.id"] = strconv.FormatInt(cachePolicy.Id, 10)