changeset 5046:2b3b0ab88c1d

fix storage cache
author Alain Mazy <am@osimis.io>
date Wed, 29 Jun 2022 08:10:28 +0200
parents a9ca92ecbbc2
children 207f259c41c5
files NEWS OrthancFramework/Sources/FileStorage/StorageAccessor.cpp
diffstat 2 files changed, 22 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Tue Jun 28 18:41:27 2022 +0200
+++ b/NEWS	Wed Jun 29 08:10:28 2022 +0200
@@ -15,6 +15,12 @@
   accessing series : 0040,0275".
   Main dicom sequences can now be returned in "MainDicomTags" and in "RequestedTags".
 
+Bug Fixes
+---------
+
+* Fix the storage cache that was not used by the Plugin SDK.  This fixes the 
+  DicomWeb plugin "/rendered" route performance issues.
+
 
 Maintenance
 -----------
--- a/OrthancFramework/Sources/FileStorage/StorageAccessor.cpp	Tue Jun 28 18:41:27 2022 +0200
+++ b/OrthancFramework/Sources/FileStorage/StorageAccessor.cpp	Wed Jun 29 08:10:28 2022 +0200
@@ -156,31 +156,23 @@
   void StorageAccessor::Read(std::string& content,
                              const FileInfo& info)
   {
-    switch (info.GetCompressionType())
+    if (!cache_.Fetch(content, info.GetUuid(), info.GetContentType()))
     {
-      case CompressionType_None:
+      switch (info.GetCompressionType())
       {
-        if (!cache_.Fetch(content, info.GetUuid(), info.GetContentType()))
+        case CompressionType_None:
         {
           MetricsTimer timer(*this, METRICS_READ);
           std::unique_ptr<IMemoryBuffer> buffer(area_.Read(info.GetUuid(), info.GetContentType()));
           buffer->MoveToString(content);
+
+          break;
         }
 
-        break;
-      }
-
-      case CompressionType_ZlibWithSize:
-      {
-        ZlibCompressor zlib;
+        case CompressionType_ZlibWithSize:
+        {
+          ZlibCompressor zlib;
 
-        std::string cached;
-        if (cache_.Fetch(cached, info.GetUuid(), info.GetContentType()))
-        {
-          zlib.Uncompress(content, cached.empty() ? NULL : cached.c_str(), cached.size());
-        }
-        else
-        {
           std::unique_ptr<IMemoryBuffer> compressed;
           
           {
@@ -189,15 +181,18 @@
           }
           
           zlib.Uncompress(content, compressed->GetData(), compressed->GetSize());
+
+          break;
         }
 
-        break;
+        default:
+        {
+          throw OrthancException(ErrorCode_NotImplemented);
+        }
       }
 
-      default:
-      {
-        throw OrthancException(ErrorCode_NotImplemented);
-      }
+      // always store the uncompressed data in cache
+      cache_.Add(info.GetUuid(), info.GetContentType(), content);
     }
 
     // TODO Check the validity of the uncompressed MD5?