Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap cache.get in try-except block #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

2 participants