diff options
| author | Stefan Boberg <[email protected]> | 2021-10-03 17:02:10 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-10-03 17:02:10 +0200 |
| commit | 4695fd893e5ad2d793c79e8cde9cb0673760893b (patch) | |
| tree | 98e35749ab4047c804dbb95fbbd81e7efd31c356 /zenserver/cache/structuredcache.cpp | |
| parent | structurec cache: Added ad hoc special case for /z$/stats.json request (diff) | |
| parent | Added support for SkipData cache policy. (diff) | |
| download | zen-4695fd893e5ad2d793c79e8cde9cb0673760893b.tar.xz zen-4695fd893e5ad2d793c79e8cde9cb0673760893b.zip | |
Merged from upstream
Diffstat (limited to 'zenserver/cache/structuredcache.cpp')
| -rw-r--r-- | zenserver/cache/structuredcache.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp index d7b409c6c..42e1d93dd 100644 --- a/zenserver/cache/structuredcache.cpp +++ b/zenserver/cache/structuredcache.cpp @@ -420,10 +420,17 @@ HttpStructuredCacheService::HandleGetCacheRecord(zen::HttpServerRequest& Request if (ValidationResult != CbValidateError::None) { ZEN_WARN("GET - '{}/{}' '{}' FAILED, invalid compact binary object", Ref.BucketSegment, Ref.HashKey, ToString(AcceptType)); + m_CacheStats.MissCount++; return Request.WriteResponse(HttpResponseCode::NotFound, HttpContentType::kText, "Invalid cache record"sv); } - const bool SkipAttachments = zen::CachePolicy::SkipAttachments == (Policy & zen::CachePolicy::SkipAttachments); + if ((Policy & CachePolicy::SkipData) == CachePolicy::SkipData) + { + m_CacheStats.HitCount++; + return Request.WriteResponse(HttpResponseCode::OK); + } + + const bool SkipAttachments = (Policy & CachePolicy::SkipAttachments) == CachePolicy::SkipAttachments; uint32_t AttachmentCount = 0; uint32_t ValidCount = 0; uint64_t AttachmentBytes = 0ull; @@ -489,7 +496,14 @@ HttpStructuredCacheService::HandleGetCacheRecord(zen::HttpServerRequest& Request m_CacheStats.UpstreamHitCount++; } - Request.WriteResponse(HttpResponseCode::OK, Value.Value.GetContentType(), Value.Value); + if ((Policy & CachePolicy::SkipData) == CachePolicy::SkipData) + { + Request.WriteResponse(HttpResponseCode::OK); + } + else + { + Request.WriteResponse(HttpResponseCode::OK, Value.Value.GetContentType(), Value.Value); + } } } @@ -742,7 +756,14 @@ HttpStructuredCacheService::HandleGetCachePayload(zen::HttpServerRequest& Reques m_CacheStats.UpstreamHitCount++; } - Request.WriteResponse(HttpResponseCode::OK, HttpContentType::kBinary, Payload); + if ((Policy & CachePolicy::SkipData) == CachePolicy::SkipData) + { + Request.WriteResponse(HttpResponseCode::OK); + } + else + { + Request.WriteResponse(HttpResponseCode::OK, HttpContentType::kBinary, Payload); + } } void |