diff options
| author | Stefan Boberg <[email protected]> | 2021-05-24 19:26:40 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-05-24 19:26:40 +0200 |
| commit | e70e2b4453a27d9d1caf77224ffd6335c50981fb (patch) | |
| tree | 05d469aa1c3ab6c1840fd4732696c708d1a2a07d /zenserver/cache/structuredcache.cpp | |
| parent | Validate payloads using embedded CompressedBuffer hash (diff) | |
| download | zen-e70e2b4453a27d9d1caf77224ffd6335c50981fb.tar.xz zen-e70e2b4453a27d9d1caf77224ffd6335c50981fb.zip | |
Added CidStore, currently used to track relationships between compressed and uncompressed chunk hashes
This first implementation is in-memory only, persistence is next
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); |