Commits

Maciej Wiśniowski committed 08cbcfb

fix to issue 14 - cache keys are using CACHE_MIDDLEWARE_PREFIX now

Comments (0)

Files changed (5)

         specific groups.
         """
         # CACHE
-        cache_key = "object-%s-%s-%s" % (self.id, user.id, codename)
+        cache_key = "%s-object-%s-%s-%s" % \
+              (settings.CACHE_MIDDLEWARE_KEY_PREFIX, self.id, user.id, codename)
         result = cache.get(cache_key)
         if result:
             return result

lfc/templatetags/lfc_tags.py

 
         # CACHE
         if lfc_context:
-            cache_key = "languages-%s-%s" % (lfc_context.id, request.user.id)
+            cache_key = "%s-languages-%s-%s" % \
+                                          (settings.CACHE_MIDDLEWARE_KEY_PREFIX,
+                                           lfc_context.id, request.user.id)
         else:
-            cache_key = "languages-none-%s" % request.user.id
+            cache_key = "%s-languages-none-%s" % \
+                                          (settings.CACHE_MIDDLEWARE_KEY_PREFIX,
+                                           request.user.id)
 
         languages = cache.get(cache_key)
 
     
     # CACHE
     if lfc_context:
-        cache_key = "tabs-%s-%s-%s-%s" % (lfc_context.content_type, lfc_context.id, request.user.id, language)
+        cache_key = "%s-tabs-%s-%s-%s-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX,
+                                             lfc_context.content_type,
+                                             lfc_context.id, request.user.id,
+                                             language)
     else:
-        cache_key = "tabs-portal-%s" % language
+        cache_key = "%s-tabs-portal-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX,
+                                           language)
 
     tabs = cache.get(cache_key)
 

lfc/utils/__init__.py

 import sys
 
 # django settings
+from django.conf import settings
 from django.core.cache import cache
 from django.core.urlresolvers import reverse
 from django.http import Http404
     """Returns the default portal.
     """
     # CACHE
-    cache_key = "portal-%s" % pk
+    cache_key = "%s-portal-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, pk)
     portal = cache.get(cache_key)
     if portal:
         return portal
     language = translation.get_language()
     
     # CACHE
-    cache_key = "traverse-obj-%s-%s-%s" % (path, request.user.id, language)
+    cache_key = "%s-traverse-obj-%s-%s-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX,
+                                              path, request.user.id, language)
     obj = cache.get(cache_key)
     if obj:
         return obj
     See there for more.
     """
     # CACHE
-    cache_key = "related-page-by-tags-%s" % page.id
+    cache_key = "%s-related-page-by-tags-%s" % \
+                                 (settings.CACHE_MIDDLEWARE_KEY_PREFIX, page.id)
     related_pages = cache.get(cache_key)
     if related_pages is not None:
         return {"related_pages" : related_pages}

lfc/utils/registration.py

 # django imports
 from django.core.cache import cache
+from django.conf import settings
 from django.contrib.contenttypes.models import ContentType
 from django.core.exceptions import ObjectDoesNotExist
 
         type = obj_or_type
 
     # CACHE
-    cache_key = "info-%s" % type
+    cache_key = "%s-info-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, type)
     result = cache.get(cache_key)
     if result:
         return result
 
     # Template
     # CACHE 
-    template_cache_key = "template-%s-%s" % (obj.content_type, obj.id)
+    template_cache_key = "%s-template-%s-%s" % \
+                (settings.CACHE_MIDDLEWARE_KEY_PREFIX, obj.content_type, obj.id)
     obj_template = cache.get(template_cache_key)
     if obj_template is None:
         obj_template = obj.get_template()
 
     # Children
     # CACHE
-    children_cache_key = "children-%s-%s-%s" % (obj.content_type, obj.id, request.user.id)
+    children_cache_key = "%s-children-%s-%s-%s" % \
+                                          (settings.CACHE_MIDDLEWARE_KEY_PREFIX,
+                                           obj.content_type, obj.id,
+                                           request.user.id)
     sub_objects = cache.get(children_cache_key)
     if sub_objects is None:
         # Get sub objects (as LOL if requested)
 
     # Images
     # CACHE
-    images_cache_key = "images-%s-%s" % (obj.content_type, obj.id)
+    images_cache_key = "%s-images-%s-%s" % \
+                                          (settings.CACHE_MIDDLEWARE_KEY_PREFIX,
+                                           obj.content_type, obj.id)
     cached_images = cache.get(images_cache_key)
     if cached_images:
         image     = cached_images["image"]