cache fix
authorNicolas DURAND <nicolas.durand@iri.centrepompidou.fr>
Thu, 16 Apr 2015 20:02:30 +0200
changeset 128 d300c7e3be20
parent 127 df984bde4bcb
child 129 d527c8f36561
cache fix
src/catedit/resources.py
src/catedit/views/utils.py
--- a/src/catedit/resources.py	Thu Apr 16 01:45:41 2015 +0200
+++ b/src/catedit/resources.py	Thu Apr 16 20:02:30 2015 +0200
@@ -41,8 +41,9 @@
         # Cache key for category key registry for this repo
         registry_key = "categories_"+repository+"_keys"
         keys_set = cache.get(registry_key)
-        
-        if keys_set is None or (keys_set is not None and cache_key not in keys_set):
+        cached_value = cache.get(cache_key)
+
+        if keys_set is None or (keys_set is not None and cache_key not in keys_set) or cached_value is None:
             rv = None
             cat_manager_instance = CategoryManager(
                 getattr(
@@ -77,7 +78,7 @@
                 cache.set(registry_key, keys_set)
             return rv
         else:
-            return cache.get(cache_key)
+            return cached_value
 
     # update category cat_id
     def put(self, repository, cat_id=None, cat_data=None, message=""):
--- a/src/catedit/views/utils.py	Thu Apr 16 01:45:41 2015 +0200
+++ b/src/catedit/views/utils.py	Thu Apr 16 20:02:30 2015 +0200
@@ -91,8 +91,9 @@
     # Cache key for comments key registry for this repo
     registry_key = "comments_"+repository+"_keys"
     keys_set = cache.get(registry_key)
-        
-    if keys_set is None or (keys_set is not None and cache_key not in keys_set):
+    cached_value = cache.get(cache_key)
+
+    if keys_set is None or (keys_set is not None and cache_key not in keys_set) or cached_value is None:
         github_comments_data = []
 
         try:
@@ -208,7 +209,7 @@
             cache.set(registry_key, keys_set)
         return rv
     else:
-        return cache.get(cache_key)
+        return cached_value
 
 def post_comment(repository, thread_type, thread_id,
                  comment_body, thread_title=""):
@@ -304,8 +305,9 @@
     # Cache key for comments key registry for this repo
     registry_key = "categories_"+repository+"_keys"
     keys_set = cache.get(registry_key)
-        
-    if keys_set is None or (keys_set is not None and cache_key not in keys_set):
+    cached_value = cache.get(cache_key)
+
+    if keys_set is None or (keys_set is not None and cache_key not in keys_set) or cached_value is None:
         commits_data = []
         try:
             commits_data = github.get(
@@ -354,7 +356,7 @@
             cache.set(registry_key, keys_set)
         return rv
     else:
-        return cache.get(cache_key)
+        return cached_value
 
 def get_issues(repository, per_page=30, page=1):
     """
@@ -378,8 +380,9 @@
     # Cache key for comments key registry for this repo
     registry_key = "comments_"+repository+"_keys"
     keys_set = cache.get(registry_key)
-        
-    if keys_set is None or (keys_set is not None and cache_key not in keys_set):
+    cached_value = cache.get(cache_key)
+
+    if keys_set is None or (keys_set is not None and cache_key not in keys_set) or cached_value is None:
         issues_data = []
         try:
             issues_data = github.get(
@@ -427,7 +430,7 @@
             cache.set(registry_key, keys_set)
         return rv
     else:
-        return cache.get(cache_key)
+        return cached_value
 
 
 def get_category_list_for_commit(repository, changeset_id, get_parent=False):