aboutsummaryrefslogtreecommitdiff
path: root/zenserver/cache/structuredcache.h
blob: d0646e6e9e9f0f8e1820104b4c759149cdb9bd37 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include <zencore/httpserver.h>

#include "cachestore.h"
#include "upstream/jupiter.h"

namespace zen {

/**
 * New-style cache service. Imposes constraints on keys, supports blobs and
 * structured values
 */

class HttpStructuredCacheService : public zen::HttpService
{
public:
	HttpStructuredCacheService(std::filesystem::path RootPath, zen::CasStore& InStore);
	~HttpStructuredCacheService();

	virtual const char* BaseUri() const override;

	virtual void HandleRequest(zen::HttpServerRequest& Request) override;

private:
	struct CacheRef
	{
		std::string BucketSegment;
		IoHash		HashKey;
	};

	[[nodiscard]] bool ValidateUri(zen::HttpServerRequest& Request, CacheRef& OutRef);

	zen::CasStore& m_CasStore;
	ZenCacheStore  m_CacheStore;
};

}  // namespace zen