aboutsummaryrefslogtreecommitdiff
path: root/zenserver/cache
diff options
context:
space:
mode:
Diffstat (limited to 'zenserver/cache')
-rw-r--r--zenserver/cache/structuredcache.cpp10
-rw-r--r--zenserver/cache/structuredcache.h4
2 files changed, 10 insertions, 4 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);
diff --git a/zenserver/cache/structuredcache.h b/zenserver/cache/structuredcache.h
index 761bf3399..63d0a0d52 100644
--- a/zenserver/cache/structuredcache.h
+++ b/zenserver/cache/structuredcache.h
@@ -11,6 +11,7 @@
namespace zen {
class CloudCacheClient;
+class CidStore;
/**
* New-style cache service. Imposes constraints on keys, supports blobs and
@@ -27,7 +28,7 @@ class CloudCacheClient;
class HttpStructuredCacheService : public zen::HttpService
{
public:
- HttpStructuredCacheService(std::filesystem::path RootPath, zen::CasStore& InStore);
+ HttpStructuredCacheService(std::filesystem::path RootPath, zen::CasStore& InStore, zen::CidStore& InCidStore);
~HttpStructuredCacheService();
virtual const char* BaseUri() const override;
@@ -47,6 +48,7 @@ private:
void HandleCachePayloadRequest(zen::HttpServerRequest& Request, CacheRef& Ref);
zen::CasStore& m_CasStore;
+ zen::CidStore& m_CidStore;
ZenCacheStore m_CacheStore;
RefPtr<CloudCacheClient> m_Cloud;
};