Skip to content

Commit

Permalink
fully set up the new cache
Browse files Browse the repository at this point in the history
  • Loading branch information
maximz committed Apr 6, 2016
1 parent 81524fe commit 84af979
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions course_selection/management/commands/clear_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ def handle(self, *args, **kwargs):
self.stdout.write('Your default cache has been cleared!\n')
caches['courses'].clear()
self.stdout.write('Your courses cache has been cleared!\n')
caches['courseapi'].clear()
self.stdout.write('Your courseapi cache has been cleared!\n')
except AttributeError:
raise CommandError('You have no cache configured!\n')
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ def handle(self, *args, **options):
data = json.dumps(results)
caches['courses'].set(term_code, data)
self.stdout.write('course selection: cache regenerated for term ' + str(term_code))
caches['courseapi'].clear()
self.stdout.write('course selection: courseapi cache cleared.')
2 changes: 1 addition & 1 deletion course_selection/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def get_users_json(request):


@require_GET
@cache_page(60 * 30) # cache for 30 minutes
@cache_page(60 * 30, cache="courseapi") # cache for 30 minutes
def get_courses_json(request, term_code):
"""
Returns list of courses for a semester
Expand Down
3 changes: 3 additions & 0 deletions settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@
'courses': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache', # overwritten in prod.py
},
'courseapi': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache', # overwritten in prod.py
},
'resources': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'TIMEOUT': 60
Expand Down
8 changes: 8 additions & 0 deletions settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ def get_cache():
'LOCATION': 'courses_cache_table',
'TIMEOUT': 60 * 60
},
'courseapi': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
'LOCATION': 'courseapi_cache_table',
'TIMEOUT': 60 * 60
}
'memcache': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'TIMEOUT': 500,
Expand All @@ -70,6 +75,9 @@ def get_cache():
},
'courses': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
},
'courseapi': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
}
}

Expand Down

0 comments on commit 84af979

Please sign in to comment.