From d6033baa726aee304a9fbe88fd2c024b3a6b5c9a Mon Sep 17 00:00:00 2001 From: Pelagic Date: Mon, 28 Aug 2023 05:03:49 +0300 Subject: [PATCH] Fixed some bugs in cache_mixins.py --- cache_mixins.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cache_mixins.py b/cache_mixins.py index a9f1395..62d1b92 100644 --- a/cache_mixins.py +++ b/cache_mixins.py @@ -78,16 +78,16 @@ class CacheSetMixin(CacheUniqueUrl): def caching_function(response): # Writes the response to the cache try: - if cls.cache_vary_on_user: - cls.cache.set(key=f"{cls.cache_prefix}.{request.user}.{self.filters_string}", + if self.cache_vary_on_user: + self.cache.set(key=f"{self.cache_prefix}.{request.user}.{self.filters_string}", value = response.data, - timeout=60*cls.cache_timeout_mins) + timeout=60*self.cache_timeout_mins) else: - cls.cache.set(key=f"{cls.cache_prefix}.{self.filters_string}", + self.cache.set(key=f"{self.cache_prefix}.{self.filters_string}", value = response.data, - timeout=60*cls.cache_timeout_mins) + timeout=60*self.cache_timeout_mins) except: - cls.logger.exception(f"Cache set attempt for {cls.__class__.__name__} failed.") + self.logger.exception(f"Cache set attempt for {self.__class__.__name__} failed.") return caching_function # Register the post rendering hook to the response @@ -119,4 +119,4 @@ class CacheDeleteMixin(CacheUniqueUrl): else: self.cache.delete(f"{self.cache_prefix}.{self.filters_string}") except: - self.logger.exception(f"Cache delete attempt for {cls.__class__.__name__} failed.") + self.logger.exception(f"Cache delete attempt for {self.__class__.__name__} failed.")