changeset 2507:99116ed6f38c

invalidate DicomCache when deleting instance
author amazy
date Mon, 26 Mar 2018 18:31:40 +0200
parents 51b91ead6c38
children 91ee08d986f9
files Core/Cache/MemoryCache.cpp Core/Cache/MemoryCache.h OrthancServer/ServerContext.cpp
diffstat 3 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Cache/MemoryCache.cpp	Mon Mar 26 17:09:42 2018 +0200
+++ b/Core/Cache/MemoryCache.cpp	Mon Mar 26 18:31:40 2018 +0200
@@ -78,6 +78,15 @@
   {
   }
 
+  void MemoryCache::Invalidate(const std::string& id)
+  {
+    if (index_.Contains(id))
+    {
+      VLOG(1) << "Invalidating a cache page";
+      index_.Invalidate(id);
+    }
+  }
+
   MemoryCache::~MemoryCache()
   {
     while (!index_.IsEmpty())
--- a/Core/Cache/MemoryCache.h	Mon Mar 26 17:09:42 2018 +0200
+++ b/Core/Cache/MemoryCache.h	Mon Mar 26 18:31:40 2018 +0200
@@ -64,5 +64,7 @@
     ~MemoryCache();
 
     IDynamicObject& Access(const std::string& id);
+
+    void Invalidate(const std::string& id);
   };
 }
--- a/OrthancServer/ServerContext.cpp	Mon Mar 26 17:09:42 2018 +0200
+++ b/OrthancServer/ServerContext.cpp	Mon Mar 26 18:31:40 2018 +0200
@@ -562,6 +562,13 @@
                                      const std::string& uuid,
                                      ResourceType expectedType)
   {
+    if (expectedType == ResourceType_Instance)
+    {
+      // remove the file from the DicomCache
+      boost::mutex::scoped_lock lock(dicomCacheMutex_);
+      dicomCache_.Invalidate(uuid);
+    }
+
     return index_.DeleteResource(target, uuid, expectedType);
   }