# HG changeset patch # User amazy # Date 1522081900 -7200 # Node ID 99116ed6f38c0b61273e8e62d5a2f24a25dd66e4 # Parent 51b91ead6c386dc715af6299ebe7a09857f7f60e invalidate DicomCache when deleting instance diff -r 51b91ead6c38 -r 99116ed6f38c Core/Cache/MemoryCache.cpp --- 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()) diff -r 51b91ead6c38 -r 99116ed6f38c Core/Cache/MemoryCache.h --- 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); }; } diff -r 51b91ead6c38 -r 99116ed6f38c OrthancServer/ServerContext.cpp --- 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); }