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 <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user