aboutsummaryrefslogtreecommitdiff
path: root/zenserver/upstream/zen.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-08-12 10:05:20 +0200
committerStefan Boberg <[email protected]>2021-08-12 10:05:20 +0200
commite664bbc31ff4ea866401c9303c53108242a6cb27 (patch)
tree71dccfc377f58042a5776db85738e3cf2e495358 /zenserver/upstream/zen.cpp
parentImplemented Flush() operation for CID/CAS store interfaces (diff)
downloadzen-e664bbc31ff4ea866401c9303c53108242a6cb27.tar.xz
zen-e664bbc31ff4ea866401c9303c53108242a6cb27.zip
Implemented flush operations for cache services
Also implemented basic upstream query interface, which needs a bit more work to be fully functional (chunk propagation / fetching and new propagation policies as per DDC requirements)
Diffstat (limited to 'zenserver/upstream/zen.cpp')
-rw-r--r--zenserver/upstream/zen.cpp97
1 files changed, 96 insertions, 1 deletions
diff --git a/zenserver/upstream/zen.cpp b/zenserver/upstream/zen.cpp
index 7904f9b28..715df6f69 100644
--- a/zenserver/upstream/zen.cpp
+++ b/zenserver/upstream/zen.cpp
@@ -7,12 +7,14 @@
#include <zencore/fmtutils.h>
#include <zencore/stream.h>
+#include "cache/structuredcachestore.h"
+
+#include <cpr/cpr.h>
#include <spdlog/spdlog.h>
#include <xxhash.h>
#include <gsl/gsl-lite.hpp>
namespace zen {
-
namespace detail {
struct MessageHeader
{
@@ -288,4 +290,97 @@ Mesh::IssueReceive()
});
}
+//////////////////////////////////////////////////////////////////////////
+
+namespace detail {
+ struct ZenCacheSessionState
+ {
+ ZenCacheSessionState(ZenStructuredCacheClient& Client) : OwnerClient(Client) {}
+ ~ZenCacheSessionState() {}
+
+ void Reset() {}
+
+ ZenStructuredCacheClient& OwnerClient;
+ cpr::Session Session;
+ };
+} // namespace detail
+
+//////////////////////////////////////////////////////////////////////////
+
+ZenStructuredCacheClient::ZenStructuredCacheClient(std::string_view ServiceUrl) : m_ServiceUrl(ServiceUrl)
+{
+}
+
+ZenStructuredCacheClient::~ZenStructuredCacheClient()
+{
+}
+
+detail::ZenCacheSessionState*
+ZenStructuredCacheClient::AllocSessionState()
+{
+ detail::ZenCacheSessionState* State = nullptr;
+
+ if (RwLock::ExclusiveLockScope _(m_SessionStateLock); !m_SessionStateCache.empty())
+ {
+ State = m_SessionStateCache.front();
+ m_SessionStateCache.pop_front();
+ }
+
+ if (State == nullptr)
+ {
+ State = new detail::ZenCacheSessionState(*this);
+ }
+
+ State->Reset();
+
+ return State;
+}
+
+void
+ZenStructuredCacheClient::FreeSessionState(detail::ZenCacheSessionState* State)
+{
+ RwLock::ExclusiveLockScope _(m_SessionStateLock);
+ m_SessionStateCache.push_front(State);
+}
+
+//////////////////////////////////////////////////////////////////////////
+
+ZenStructuredCacheSession::ZenStructuredCacheSession(ZenStructuredCacheClient& OuterClient) : m_Client(OuterClient)
+{
+}
+
+ZenStructuredCacheSession::~ZenStructuredCacheSession()
+{
+}
+
+IoBuffer
+ZenStructuredCacheSession::Get(std::string_view BucketId, std::string_view Key)
+{
+ ZEN_UNUSED(BucketId, Key);
+
+ return {};
+}
+
+void
+ZenStructuredCacheSession::Put(std::string_view BucketId, std::string_view Key, IoBuffer Data)
+{
+ ZEN_UNUSED(BucketId, Key, Data);
+}
+
+// Structured cache operations
+
+IoBuffer
+ZenStructuredCacheSession::Get(std::string_view BucketId, const IoHash& Key)
+{
+ ZEN_UNUSED(BucketId, Key);
+
+ return {};
+}
+
+void
+ZenStructuredCacheSession::Put(std::string_view BucketId, const IoHash& Key, ZenCacheValue Data)
+{
+ ZEN_UNUSED(BucketId, Key, Data);
+}
+
} // namespace zen