aboutsummaryrefslogtreecommitdiff
path: root/zenutil/include
diff options
context:
space:
mode:
Diffstat (limited to 'zenutil/include')
-rw-r--r--zenutil/include/zenutil/cache/cachekey.h41
1 files changed, 20 insertions, 21 deletions
diff --git a/zenutil/include/zenutil/cache/cachekey.h b/zenutil/include/zenutil/cache/cachekey.h
index aa649b4dc..427c99435 100644
--- a/zenutil/include/zenutil/cache/cachekey.h
+++ b/zenutil/include/zenutil/cache/cachekey.h
@@ -12,33 +12,32 @@ namespace zen {
struct CacheKey
{
+ std::string Namespace;
std::string Bucket;
IoHash Hash;
- static CacheKey Create(std::string_view Bucket, const IoHash& Hash) { return {.Bucket = ToLower(Bucket), .Hash = Hash}; }
-
- static const CacheKey Empty;
-};
+ static CacheKey Create(std::string_view Namespace, std::string_view Bucket, const IoHash& Hash)
+ {
+ return {.Namespace = ToLower(Namespace), .Bucket = ToLower(Bucket), .Hash = Hash};
+ }
-inline bool
-operator==(const CacheKey& A, const CacheKey& B)
-{
- return A.Bucket == B.Bucket && A.Hash == B.Hash;
-}
+ auto operator<=>(const CacheKey& that) const
+ {
+ if (auto n = caseSensitiveCompareStrings(Namespace, that.Namespace); n != std::strong_ordering::equal)
+ {
+ return n;
+ }
+ if (auto b = caseSensitiveCompareStrings(Bucket, that.Bucket); b != std::strong_ordering::equal)
+ {
+ return b;
+ }
+ return Hash <=> that.Hash;
+ }
-inline bool
-operator!=(const CacheKey& A, const CacheKey& B)
-{
- return A.Bucket != B.Bucket || A.Hash != B.Hash;
-}
+ auto operator==(const CacheKey& that) const { return (*this <=> that) == std::strong_ordering::equal; }
-inline bool
-operator<(const CacheKey& A, const CacheKey& B)
-{
- const std::string& BucketA = A.Bucket;
- const std::string& BucketB = B.Bucket;
- return BucketA == BucketB ? A.Hash < B.Hash : BucketA < BucketB;
-}
+ static const CacheKey Empty;
+};
struct CacheChunkRequest
{