changeset 1137:cc029987b6dc broker

improved cache key
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 06 Nov 2019 20:27:20 +0100
parents 42581a6182c8
children 1a73f852810a
files Framework/Oracle/GenericOracleRunner.cpp
diffstat 1 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Oracle/GenericOracleRunner.cpp	Wed Nov 06 17:54:14 2019 +0100
+++ b/Framework/Oracle/GenericOracleRunner.cpp	Wed Nov 06 20:27:20 2019 +0100
@@ -249,14 +249,13 @@
 
       virtual void Handle(Orthanc::ParsedDicomFile* dicom,
                           const ParseDicomFileCommand& command,
+                          const std::string& path,
                           uint64_t fileSize) = 0;
 
       static void Apply(IDicomHandler& handler,
-                        const std::string& root,
+                        const std::string& path,
                         const ParseDicomFileCommand& command)
       {
-        std::string path = GetPath(root, command.GetPath());
-
         if (!Orthanc::SystemToolbox::IsRegularFile(path))
         {
           throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentFile);
@@ -298,7 +297,7 @@
 
         if (ok)
         {
-          handler.Handle(new Orthanc::ParsedDicomFile(dicom), command, fileSize);
+          handler.Handle(new Orthanc::ParsedDicomFile(dicom), command, path, fileSize);
         }
         else
         {
@@ -325,6 +324,7 @@
       
       virtual void Handle(Orthanc::ParsedDicomFile* dicom,
                           const ParseDicomFileCommand& command,
+                          const std::string& path,
                           uint64_t fileSize)
       {
         std::auto_ptr<Orthanc::ParsedDicomFile> parsed(dicom);
@@ -359,6 +359,7 @@
       
       virtual void Handle(Orthanc::ParsedDicomFile* dicom,
                           const ParseDicomFileCommand& command,
+                          const std::string& path,
                           uint64_t fileSize)
       {
         std::auto_ptr<Orthanc::ParsedDicomFile> parsed(dicom);
@@ -371,7 +372,7 @@
 
         // Store it into the cache for future use
         assert(cache_);
-        cache_->Acquire(command.GetPath(), parsed.release(),
+        cache_->Acquire(path, parsed.release(),
                         static_cast<size_t>(fileSize), command.IsPixelDataIncluded());
       }
     };
@@ -384,11 +385,13 @@
                           const std::string& root,
                           const ParseDicomFileCommand& command)
   {
+    const std::string path = GetPath(root, command.GetPath());
+
 #if 1
     if (cache.get())
     {
       {
-        ParsedDicomFileCache::Reader reader(*cache, command.GetPath());
+        ParsedDicomFileCache::Reader reader(*cache, path);
         if (reader.IsValid() &&
             (!command.IsPixelDataIncluded() ||
              reader.HasPixelData()))
@@ -402,17 +405,17 @@
       }
       
       DicomHandlerWithCache handler(receiver, emitter, cache);
-      IDicomHandler::Apply(handler, root, command);
+      IDicomHandler::Apply(handler, path, command);
     }
     else
     {
       // No cache available
       DicomHandlerWithoutCache handler(receiver, emitter);
-      IDicomHandler::Apply(handler, root, command);
+      IDicomHandler::Apply(handler, path, command);
     }
 #else
     DicomHandlerWithoutCache handler(receiver, emitter);
-    IDicomHandler::Apply(handler, root, command);
+    IDicomHandler::Apply(handler, path, command);
 #endif
   }