diff options
Diffstat (limited to 'zenserver/cache/structuredcache.cpp')
| -rw-r--r-- | zenserver/cache/structuredcache.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp index 317c5641a..43364af1d 100644 --- a/zenserver/cache/structuredcache.cpp +++ b/zenserver/cache/structuredcache.cpp @@ -12,6 +12,7 @@ #include "structuredcache.h" #include "structuredcachestore.h" #include "upstream/jupiter.h" +#include "zenstore/cidstore.h" #include <spdlog/spdlog.h> #include <filesystem> @@ -20,9 +21,10 @@ namespace zen { using namespace std::literals; -HttpStructuredCacheService::HttpStructuredCacheService(std::filesystem::path RootPath, zen::CasStore& InStore) +HttpStructuredCacheService::HttpStructuredCacheService(std::filesystem::path RootPath, zen::CasStore& InStore, zen::CidStore& InCidStore) : m_CasStore(InStore) , m_CacheStore(InStore, RootPath) +, m_CidStore(InCidStore) { spdlog::info("initializing structured cache at '{}'", RootPath); @@ -144,7 +146,7 @@ HttpStructuredCacheService::HandleCacheRecordRequest(zen::HttpServerRequest& Req if (!References.empty()) { zen::CbObjectWriter Idx; - Idx.BeginArray(); + Idx.BeginArray("r"); for (const IoHash& Hash : References) { @@ -222,7 +224,7 @@ HttpStructuredCacheService::HandleCachePayloadRequest(zen::HttpServerRequest& Re // TODO: need to map from uncompressed content address into the storage // (compressed) content address - zen::IoBuffer Payload = m_CasStore.FindChunk(Ref.PayloadId); + zen::IoBuffer Payload = m_CidStore.FindChunkByCid(Ref.PayloadId); if (!Payload) { @@ -254,6 +256,8 @@ HttpStructuredCacheService::HandleCachePayloadRequest(zen::HttpServerRequest& Re zen::CasStore::InsertResult Result = m_CasStore.InsertChunk(Body, ChunkHash); + m_CidStore.AddCompressedCid(Ref.PayloadId, ChunkHash); + if (Result.New) { return Request.WriteResponse(zen::HttpResponse::Created); |