aboutsummaryrefslogtreecommitdiff
path: root/zenserver/upstream/upstreamcache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zenserver/upstream/upstreamcache.cpp')
-rw-r--r--zenserver/upstream/upstreamcache.cpp48
1 files changed, 47 insertions, 1 deletions
diff --git a/zenserver/upstream/upstreamcache.cpp b/zenserver/upstream/upstreamcache.cpp
index 437b29cd7..7ef0caf62 100644
--- a/zenserver/upstream/upstreamcache.cpp
+++ b/zenserver/upstream/upstreamcache.cpp
@@ -782,7 +782,7 @@ public:
virtual GetUpstreamCacheBatchResult GetCacheRecords(std::span<CacheKey> CacheKeys,
std::span<size_t> KeyIndex,
- OnCacheGetComplete OnComplete) override
+ OnCacheGetComplete OnComplete) override final
{
if (!m_Options.ReadUpstream)
{
@@ -801,6 +801,52 @@ public:
if (Endpoint->IsHealthy())
{
CacheResult = Endpoint->GetCacheRecord(CacheKey, ZenContentType::kCbPackage);
+ m_Stats.Add(m_Log, *Endpoint, CacheResult, m_Endpoints);
+
+ if (CacheResult.Success)
+ {
+ break;
+ }
+ }
+ }
+
+ if (CacheResult.Success)
+ {
+ OnComplete(Idx, CacheResult.Value);
+ }
+ else
+ {
+ Result.Missing.push_back(Idx);
+ }
+ }
+
+ return Result;
+ }
+
+ virtual GetUpstreamCacheBatchResult GetCachePayloads(std::span<CacheChunkRequest> CacheChunkRequests,
+ std::span<size_t> ChunkIndex,
+ OnCacheGetComplete OnComplete) override final
+ {
+ if (!m_Options.ReadUpstream)
+ {
+ return {.Missing = std::vector<size_t>(ChunkIndex.begin(), ChunkIndex.end())};
+ }
+
+ GetUpstreamCacheBatchResult Result;
+
+ for (size_t Idx : ChunkIndex)
+ {
+ const CacheChunkRequest& Chunk = CacheChunkRequests[Idx];
+ UpstreamPayloadKey PayloadKey{{Chunk.Key.Bucket, Chunk.Key.Hash}, Chunk.ChunkId};
+
+ GetUpstreamCacheResult CacheResult;
+ for (auto& Endpoint : m_Endpoints)
+ {
+ if (Endpoint->IsHealthy())
+ {
+ CacheResult = Endpoint->GetCachePayload(PayloadKey);
+ m_Stats.Add(m_Log, *Endpoint, CacheResult, m_Endpoints);
+
if (CacheResult.Success)
{
break;