diff options
Diffstat (limited to 'src/zenserver/cache/structuredcachestore.cpp')
| -rw-r--r-- | src/zenserver/cache/structuredcachestore.cpp | 75 |
1 files changed, 73 insertions, 2 deletions
diff --git a/src/zenserver/cache/structuredcachestore.cpp b/src/zenserver/cache/structuredcachestore.cpp index 79f57019d..a95ae4ca2 100644 --- a/src/zenserver/cache/structuredcachestore.cpp +++ b/src/zenserver/cache/structuredcachestore.cpp @@ -2497,12 +2497,16 @@ ZenCacheDiskLayer::GetValueDetails(const std::string_view BucketFilter, const st //////////////////////////// ZenCacheStore -static constexpr std::string_view UE4DDCNamespaceName = "ue4.ddc"; +ZEN_DEFINE_LOG_CATEGORY_STATIC(LogCacheActivity, "z$"); + +static constinit std::string_view UE4DDCNamespaceName = "ue4.ddc"; ZenCacheStore::ZenCacheStore(GcManager& Gc, const Configuration& Configuration) : m_Gc(Gc), m_Configuration(Configuration) { CreateDirectories(m_Configuration.BasePath); + ZEN_INFO("Initializing at '{}'", m_Configuration.BasePath); + DirectoryContent DirContent; GetDirectoryContent(m_Configuration.BasePath, DirectoryContent::IncludeDirsFlag, DirContent); @@ -2546,7 +2550,45 @@ ZenCacheStore::Get(std::string_view Namespace, std::string_view Bucket, const Io { if (ZenCacheNamespace* Store = GetNamespace(Namespace); Store) { - return Store->Get(Bucket, HashKey, OutValue); + bool Result = Store->Get(Bucket, HashKey, OutValue); + + if (m_Configuration.EnableAccessLog) + { + if (Result) + { + if (OutValue.Value.GetContentType() == ZenContentType::kCbObject) + { + const IoHash ObjectHash = IoHash::HashBuffer(OutValue.Value.GetView()); + const size_t ObjectSize = OutValue.Value.GetSize(); + + ZEN_LOG_INFO(LogCacheActivity, + "GET HIT {}/{}/{} -> {} {} {}", + Namespace, + Bucket, + HashKey, + ObjectHash, + ObjectSize, + ToString(OutValue.Value.GetContentType())) + } + else + { + ZEN_LOG_INFO(LogCacheActivity, + "GET HIT {}/{}/{} -> {} {} {}", + Namespace, + Bucket, + HashKey, + OutValue.RawHash, + OutValue.RawSize, + ToString(OutValue.Value.GetContentType())); + } + } + else + { + ZEN_LOG_INFO(LogCacheActivity, "GET MISS {}/{}/{}", Namespace, Bucket, HashKey); + } + } + + return Result; } ZEN_WARN("request for unknown namespace '{}' in ZenCacheStore::Get, bucket '{}', key '{}'", Namespace, Bucket, HashKey.ToHexString()); @@ -2556,6 +2598,35 @@ ZenCacheStore::Get(std::string_view Namespace, std::string_view Bucket, const Io void ZenCacheStore::Put(std::string_view Namespace, std::string_view Bucket, const IoHash& HashKey, const ZenCacheValue& Value) { + if (m_Configuration.EnableWriteLog) + { + if (Value.Value.GetContentType() == ZenContentType::kCbObject) + { + const IoHash ObjectHash = IoHash::HashBuffer(Value.Value.GetView()); + const size_t ObjectSize = Value.Value.GetSize(); + + ZEN_LOG_INFO(LogCacheActivity, + "PUT {}/{}/{} -> {} {} {}", + Namespace, + Bucket, + HashKey, + ObjectHash, + ObjectSize, + ToString(Value.Value.GetContentType())); + } + else + { + ZEN_LOG_INFO(LogCacheActivity, + "PUT {}/{}/{} -> {} {} {}", + Namespace, + Bucket, + HashKey, + Value.RawHash, + Value.RawSize, + ToString(Value.Value.GetContentType())); + } + } + if (ZenCacheNamespace* Store = GetNamespace(Namespace); Store) { return Store->Put(Bucket, HashKey, Value); |