Shift wiki and course.xml caching to use newly defined 'general' cache, separate from sessions left in 'default'

--HG--
branch : cache_separation
This commit is contained in:
David Ormsbee
2012-03-15 14:45:27 -04:00
parent 11f4820704
commit e37eb49065
3 changed files with 20 additions and 2 deletions

View File

@@ -11,10 +11,11 @@ from lxml import etree
try: # This lets us do __name__ == ='__main__'
from django.conf import settings
from django.core.cache import cache
from student.models import UserProfile
from student.models import UserTestGroup
from mitxmako.shortcuts import render_to_response, render_to_string
from util.cache import cache
except:
settings = None

View File

@@ -3,7 +3,6 @@ import os
from django import forms
from django.contrib.auth.models import User
from django.core.cache import cache
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models import signals
@@ -11,6 +10,8 @@ from django.utils.translation import ugettext_lazy as _
from markdown import markdown
from settings import *
from util.cache import cache
class ShouldHaveExactlyOneRootSlug(Exception):
pass

16
util/cache.py Normal file
View File

@@ -0,0 +1,16 @@
"""
This module aims to give a little more fine-tuned control of caching and cache
invalidation. Import these instead of django.core.cache.
Note that 'default' is being preserved for user session caching, which we're
not migrating so as not to inconvenience users by logging them all out.
"""
from django.core import cache
# If we can't find a 'general' CACHE defined in settings.py, we simply fall back
# to returning the default cache. This will happen with dev machines.
try:
cache = cache.get_cache('general')
except ValueError:
cache = cache.cache