aboutsummaryrefslogtreecommitdiff
path: root/zenserver/cache/cachekey.h
diff options
context:
space:
mode:
authorPer Larsson <[email protected]>2021-11-02 10:50:18 +0100
committerPer Larsson <[email protected]>2021-11-02 10:50:18 +0100
commit4b8d4c0e375c729e38bdaadfebf0eaf14f08f5f9 (patch)
treed1e6fb1c71a0c8c5e12b2814f309d09d7093c9b3 /zenserver/cache/cachekey.h
parentMerge branch 'main' into zcache-batch (diff)
downloadzen-4b8d4c0e375c729e38bdaadfebf0eaf14f08f5f9.tar.xz
zen-4b8d4c0e375c729e38bdaadfebf0eaf14f08f5f9.zip
Added upstream batch API.
Diffstat (limited to 'zenserver/cache/cachekey.h')
-rw-r--r--zenserver/cache/cachekey.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/zenserver/cache/cachekey.h b/zenserver/cache/cachekey.h
new file mode 100644
index 000000000..eba063699
--- /dev/null
+++ b/zenserver/cache/cachekey.h
@@ -0,0 +1,52 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#pragma once
+
+#include <zencore/iohash.h>
+#include <zencore/string.h>
+#include <gsl/gsl-lite.hpp>
+
+namespace zen {
+
+enum class CachePolicy : uint8_t
+{
+ None = 0,
+ QueryLocal = 1 << 0,
+ QueryRemote = 1 << 1,
+ Query = QueryLocal | QueryRemote,
+ StoreLocal = 1 << 2,
+ StoreRemote = 1 << 3,
+ Store = StoreLocal | StoreRemote,
+ SkipMeta = 1 << 4,
+ SkipValue = 1 << 5,
+ SkipAttachments = 1 << 6,
+ SkipData = SkipMeta | SkipValue | SkipAttachments,
+ SkipLocalCopy = 1 << 7,
+ Local = QueryLocal | StoreLocal,
+ Remote = QueryRemote | StoreRemote,
+ Default = Query | Store,
+ Disable = None,
+};
+
+gsl_DEFINE_ENUM_BITMASK_OPERATORS(CachePolicy);
+
+CachePolicy ParseQueryCachePolicy(std::string_view QueryPolicy, CachePolicy Default = CachePolicy::Query);
+
+CachePolicy ParseStoreCachePolicy(std::string_view StorePolicy, CachePolicy Default = CachePolicy::Store);
+
+CachePolicy ParseSkipCachePolicy(std::string_view SkipPolicy, CachePolicy Default = CachePolicy::None);
+
+struct CacheKey
+{
+ std::string Bucket;
+ IoHash Hash;
+
+ static CacheKey Create(std::string_view Bucket, const IoHash& Hash)
+ {
+ return {.Bucket = ToLower(Bucket), .Hash = Hash};
+ }
+
+ static CacheKey None;
+};
+
+} // namespace zen