Mercurial > hg > orthanc
changeset 4826:6c276fac0cc0
fix storage cache for user attachment -> the cache is ignoring them
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 25 Nov 2021 15:36:11 +0100 |
parents | 381c2ca04860 |
children | 2425fa7bd50d a678ff1b8278 |
files | OrthancFramework/Sources/FileStorage/StorageCache.cpp |
diffstat | 1 files changed, 28 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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; }