# HG changeset patch # User Alain Mazy # Date 1637850971 -3600 # Node ID 6c276fac0cc024d98f2120e2cd1c067141e98efd # Parent 381c2ca04860c70dab38bcdbbd1e8d143ecb84af fix storage cache for user attachment -> the cache is ignoring them diff -r 381c2ca04860 -r 6c276fac0cc0 OrthancFramework/Sources/FileStorage/StorageCache.cpp --- a/OrthancFramework/Sources/FileStorage/StorageCache.cpp Thu Nov 25 13:58:10 2021 +0100 +++ b/OrthancFramework/Sources/FileStorage/StorageCache.cpp Thu Nov 25 15:36:11 2021 +0100 @@ -53,9 +53,16 @@ } } - void GetCacheKey(std::string& key, const std::string& uuid, FileContentType contentType) + bool GetCacheKey(std::string& key, const std::string& uuid, FileContentType contentType) { + if (contentType == FileContentType_Unknown || contentType >= FileContentType_StartUser) + { + return false; + } + key = uuid + ":" + std::string(ToString(contentType)); + + return true; } void StorageCache::SetMaximumSize(size_t size) @@ -73,8 +80,11 @@ } std::string key; - GetCacheKey(key, uuid, contentType); - cache_.Add(key, value); + + if (GetCacheKey(key, uuid, contentType)) + { + cache_.Add(key, value); + } } void StorageCache::Add(const std::string& uuid, @@ -88,15 +98,21 @@ } std::string key; - GetCacheKey(key, uuid, contentType); - cache_.Add(key, buffer, size); + + if (GetCacheKey(key, uuid, contentType)) + { + cache_.Add(key, buffer, size); + } } void StorageCache::Invalidate(const std::string& uuid, FileContentType contentType) { std::string key; - GetCacheKey(key, uuid, contentType); - cache_.Invalidate(key); + + if (GetCacheKey(key, uuid, contentType)) + { + cache_.Invalidate(key); + } } bool StorageCache::Fetch(std::string& value, @@ -109,9 +125,12 @@ } std::string key; - GetCacheKey(key, uuid, contentType); + if (GetCacheKey(key, uuid, contentType)) + { + return cache_.Fetch(value, key); + } - return cache_.Fetch(value, key); + return false; }