From d0dbe7c6e648f6943a0ef47c0edc087cb79b709e Mon Sep 17 00:00:00 2001 From: Jean-Baptiste <bleme@pm.me> Date: Fri, 23 Oct 2020 17:11:36 +0200 Subject: [PATCH] update: improve max_age but reset all caches at each update --- djangoldp/models.py | 9 ++------- djangoldp/serializers.py | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/djangoldp/models.py b/djangoldp/models.py index 7847b300..2c5e4511 100644 --- a/djangoldp/models.py +++ b/djangoldp/models.py @@ -370,10 +370,5 @@ def invalidate_caches(instance, **kwargs): if isinstance(instance, Model): from djangoldp.serializers import LDListMixin, LDPSerializer LDPPermissions.invalidate_cache() - try: - LDListMixin.to_representation_cache.invalidate(Model.absolute_url(instance._meta.model)) - LDPSerializer.to_representation_cache.invalidate(Model.absolute_url(instance._meta.model)) - LDListMixin.to_representation_cache.invalidate(Model.absolute_url(instance)) - LDPSerializer.to_representation_cache.invalidate(Model.absolute_url(instance)) - except NoReverseMatch: - pass + LDListMixin.to_representation_cache.reset() + LDPSerializer.to_representation_cache.reset() diff --git a/djangoldp/serializers.py b/djangoldp/serializers.py index 84a6625b..d4c63222 100644 --- a/djangoldp/serializers.py +++ b/djangoldp/serializers.py @@ -32,7 +32,7 @@ from djangoldp.permissions import LDPPermissions class InMemoryCache: - def __init__(self, max_age=30): + def __init__(self, max_age=3000): self.max_age = max_age self.cache = { } -- GitLab