aboutsummaryrefslogtreecommitdiff
path: root/zenserver/cache/structuredcachestore.h
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-05-04 19:45:57 +0200
committerDan Engelbrecht <[email protected]>2022-05-04 19:55:07 +0200
commitef12415d287c9307c0c4774aeacff6c91966f693 (patch)
tree34f436c3108249b28b120abd6b2346ac2e6251f5 /zenserver/cache/structuredcachestore.h
parentdefault namespace fix (diff)
downloadzen-ef12415d287c9307c0c4774aeacff6c91966f693.tar.xz
zen-ef12415d287c9307c0c4774aeacff6c91966f693.zip
cleanup
Diffstat (limited to 'zenserver/cache/structuredcachestore.h')
-rw-r--r--zenserver/cache/structuredcachestore.h33
1 files changed, 28 insertions, 5 deletions
diff --git a/zenserver/cache/structuredcachestore.h b/zenserver/cache/structuredcachestore.h
index 0c2a7c0b2..a803b0603 100644
--- a/zenserver/cache/structuredcachestore.h
+++ b/zenserver/cache/structuredcachestore.h
@@ -322,11 +322,11 @@ private:
ZenCacheDiskLayer& operator=(const ZenCacheDiskLayer&) = delete;
};
-class ZenCacheStore final : public GcStorage, public GcContributor
+class ZenCacheNamespace final : public RefCounted, public GcStorage, public GcContributor
{
public:
- ZenCacheStore(CasGc& Gc, const std::filesystem::path& RootDir);
- ~ZenCacheStore();
+ ZenCacheNamespace(CasGc& Gc, const std::filesystem::path& RootDir);
+ ~ZenCacheNamespace();
bool Get(std::string_view Bucket, const IoHash& HashKey, ZenCacheValue& OutValue);
void Put(std::string_view Bucket, const IoHash& HashKey, const ZenCacheValue& Value);
@@ -349,8 +349,31 @@ private:
std::unique_ptr<ZenCacheTracker> m_AccessTracker;
#endif
- ZenCacheStore(const ZenCacheStore&) = delete;
- ZenCacheStore& operator=(const ZenCacheStore&) = delete;
+ ZenCacheNamespace(const ZenCacheNamespace&) = delete;
+ ZenCacheNamespace& operator=(const ZenCacheNamespace&) = delete;
+};
+
+class ZenCacheStore final : public GcStorage, public GcContributor
+{
+public:
+ ZenCacheStore(std::filesystem::path BasePath, CasGc& Gc);
+ ~ZenCacheStore();
+
+ bool Get(const std::string& Namespace, std::string_view Bucket, const IoHash& HashKey, ZenCacheValue& OutValue);
+ void Put(const std::string& Namespace, std::string_view Bucket, const IoHash& HashKey, const ZenCacheValue& Value);
+ bool DropBucket(const std::string& Namespace, std::string_view Bucket);
+ void Flush();
+ void Scrub(ScrubContext& Ctx);
+
+ virtual void GatherReferences(GcContext& GcCtx) override;
+ virtual void CollectGarbage(GcContext& GcCtx) override;
+ virtual GcStorageSize StorageSize() const override;
+
+private:
+ Ref<ZenCacheNamespace> GetStore(const std::string& Namespace);
+ std::vector<Ref<ZenCacheNamespace>> GetAllStores() const;
+ mutable RwLock m_NamespacesLock;
+ std::unordered_map<std::string, Ref<ZenCacheNamespace>> m_Namespaces;
};
void z$_forcelink();