Skip to content

Conversation

@Anton-Shutik
Copy link
Collaborator

@Anton-Shutik Anton-Shutik commented Jul 14, 2021

Wrapped cache.get in try-except block

Copy link

@tochiaigrove tochiaigrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could work. I wonder what you think of this as an alternative, or as an additional change:

diff --git a/django_elasticache/memcached.py b/django_elasticache/memcached.py
index 4f7775f..19aa937 100644
--- a/django_elasticache/memcached.py
+++ b/django_elasticache/memcached.py
@@ -13,13 +13,15 @@ def invalidate_cache_after_error(f):
     """
     catch any exception and invalidate internal cache with list of nodes
     """
+
     @wraps(f)
     def wrapper(self, *args, **kwds):
         try:
             return f(self, *args, **kwds)
         except Exception:
             self.clear_cluster_nodes_cache()
-            raise
+            return f(self, *args, **kwds)
+
     return wrapper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants