diff options
| author | mattpetersepic <[email protected]> | 2022-02-01 08:06:36 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-02-01 08:06:36 -0700 |
| commit | 154743f2d2ff2b7163bcf8d7b76eea3e3579aaba (patch) | |
| tree | aef417b5c9a0d5502c7afdb01c4cc598071e956d /zenserver/upstream/upstreamcache.h | |
| parent | Tweaked remote_build.py TTY output (diff) | |
| download | zen-154743f2d2ff2b7163bcf8d7b76eea3e3579aaba.tar.xz zen-154743f2d2ff2b7163bcf8d7b76eea3e3579aaba.zip | |
Cache policy support (#47)
Add HandleRpc methods for the remaining ICacheStore requests from unreal: PutCacheValues/GetCacheValues. We now have batched versions for PutCacheRecords,GetCacheRecords,PutCacheValues,GetCacheValues,GetCacheChunks. Add support for CachePolicy flags to all of these batched methods.
* Add Batched PutCacheValues/GetCacheValues. Rename old GetCacheValues to GetCacheChunks.
* HandleRpcGetCacheRecords: Receive a CacheRecordPolicy with each key, and skipdata on attachments we already have.
* Changes to CachePolicy copied from Release-5.0 depot. Change serialization to use the key BasePolicy instead of DefaultValuePolicy.
* GetChunks: Read CacheRecords from remote if necessary to find ContentId. Implement QueryLocal, StoreLocal, and SkipData.
Diffstat (limited to 'zenserver/upstream/upstreamcache.h')
| -rw-r--r-- | zenserver/upstream/upstreamcache.h | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/zenserver/upstream/upstreamcache.h b/zenserver/upstream/upstreamcache.h index 2087b1fba..994129fc4 100644 --- a/zenserver/upstream/upstreamcache.h +++ b/zenserver/upstream/upstreamcache.h @@ -2,6 +2,8 @@ #pragma once +#include <zencore/compactbinary.h> +#include <zencore/compress.h> #include <zencore/iobuffer.h> #include <zencore/iohash.h> #include <zencore/stats.h> @@ -12,10 +14,10 @@ #include <chrono> #include <functional> #include <memory> +#include <vector> namespace zen { -class CbObjectView; class CbPackage; class CbObjectWriter; class CidStore; @@ -65,8 +67,7 @@ struct PutUpstreamCacheResult struct CacheRecordGetCompleteParams { - const CacheKey& Key; - size_t KeyIndex = ~size_t(0); + CacheKeyRequest& Request; const CbObjectView& Record; const CbPackage& Package; }; @@ -75,9 +76,10 @@ using OnCacheRecordGetComplete = std::function<void(CacheRecordGetCompleteParams struct CacheValueGetCompleteParams { - const CacheChunkRequest& Request; - size_t RequestIndex{~size_t(0)}; - IoBuffer Value; + CacheChunkRequest& Request; + IoHash RawHash; + uint64_t RawSize; + IoBuffer Value; }; using OnCacheValueGetComplete = std::function<void(CacheValueGetCompleteParams&&)>; @@ -151,16 +153,12 @@ public: virtual GetUpstreamCacheResult GetCacheRecord(CacheKey CacheKey, ZenContentType Type) = 0; - virtual GetUpstreamCacheResult GetCacheRecords(std::span<CacheKey> CacheKeys, - std::span<size_t> KeyIndex, - const CacheRecordPolicy& Policy, - OnCacheRecordGetComplete&& OnComplete) = 0; + virtual GetUpstreamCacheResult GetCacheRecords(std::span<CacheKeyRequest*> Requests, OnCacheRecordGetComplete&& OnComplete) = 0; virtual GetUpstreamCacheResult GetCacheValue(const CacheKey& CacheKey, const IoHash& PayloadId) = 0; - virtual GetUpstreamCacheResult GetCacheValues(std::span<CacheChunkRequest> CacheChunkRequests, - std::span<size_t> RequestIndex, - OnCacheValueGetComplete&& OnComplete) = 0; + virtual GetUpstreamCacheResult GetCacheValues(std::span<CacheChunkRequest*> CacheChunkRequests, + OnCacheValueGetComplete&& OnComplete) = 0; virtual PutUpstreamCacheResult PutCacheRecord(const UpstreamCacheRecord& CacheRecord, IoBuffer RecordValue, @@ -185,16 +183,11 @@ public: virtual GetUpstreamCacheResult GetCacheRecord(CacheKey CacheKey, ZenContentType Type) = 0; - virtual void GetCacheRecords(std::span<CacheKey> CacheKeys, - std::span<size_t> KeyIndex, - const CacheRecordPolicy& RecordPolicy, - OnCacheRecordGetComplete&& OnComplete) = 0; + virtual void GetCacheRecords(std::span<CacheKeyRequest*> Requests, OnCacheRecordGetComplete&& OnComplete) = 0; virtual GetUpstreamCacheResult GetCacheValue(const CacheKey& CacheKey, const IoHash& ValueContentId) = 0; - virtual void GetCacheValues(std::span<CacheChunkRequest> CacheChunkRequests, - std::span<size_t> RequestIndex, - OnCacheValueGetComplete&& OnComplete) = 0; + virtual void GetCacheValues(std::span<CacheChunkRequest*> CacheChunkRequests, OnCacheValueGetComplete&& OnComplete) = 0; virtual void EnqueueUpstream(UpstreamCacheRecord CacheRecord) = 0; |