Mercurial > hg > orthanc
changeset 6783:39623af8186d
allow loaded value to bypass the reader cache
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Wed, 13 May 2026 08:58:08 +0200 |
| parents | e8c6f6cc27f2 |
| children | 40683448f9ae |
| files | OrthancFramework/Sources/DataSource/DataSourceReader.cpp OrthancFramework/Sources/DataSource/IDataIdentifier.h |
| diffstat | 2 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DataSource/DataSourceReader.cpp Wed May 13 08:44:52 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/DataSourceReader.cpp Wed May 13 08:58:08 2026 +0200 @@ -70,9 +70,12 @@ boost::shared_ptr<IDynamicObject> value; std::unique_ptr<OrthancException> error; - if (cache_) + std::string cacheKey; + bool hasCacheKey = id_->GetCacheKey(cacheKey); + + if (cache_ && hasCacheKey) { - value = cache_->GetCachedValue(id_->GetCacheKey()); + value = cache_->GetCachedValue(cacheKey); } if (!value) @@ -95,9 +98,9 @@ error.reset(new OrthancException(ErrorCode_NullPointer)); } - if (!error && cache_) + if (!error && cache_ && hasCacheKey) { - cache_->Store(id_->GetCacheKey(), value); + cache_->Store(cacheKey, value); } }
--- a/OrthancFramework/Sources/DataSource/IDataIdentifier.h Wed May 13 08:44:52 2026 +0200 +++ b/OrthancFramework/Sources/DataSource/IDataIdentifier.h Wed May 13 08:58:08 2026 +0200 @@ -38,6 +38,7 @@ { } - virtual std::string GetCacheKey() const = 0; + // If this method return "false", the loaded value bypasses the reader cache (if present) + virtual bool GetCacheKey(std::string& key) const = 0; }; }
