From 1515c0170f78821172c69e506363fd74308a531a Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 4 Dec 2018 15:46:05 -0400 Subject: [PATCH] Cache: Prune the cache on property updates Execute the prune method of a cache when its properties are changed. This ensures the size of the cache matches the maximum size set when last saved. Signed-off-by: Roberto Rosario --- mayan/apps/common/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mayan/apps/common/models.py b/mayan/apps/common/models.py index f66859d444..b4be090857 100644 --- a/mayan/apps/common/models.py +++ b/mayan/apps/common/models.py @@ -64,6 +64,11 @@ class Cache(models.Model): for partition in self.partitions.all(): partition.purge() + def save(self, *args, **kwargs): + result = super(Cache, self).save(*args, **kwargs) + self.prune() + return result + @cached_property def storage(self): return import_string(self.storage_instance_path)