Fixed some bugs in cache_mixins.py
This commit is contained in:
@@ -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.")
|
||||
|
||||
Reference in New Issue
Block a user