From 0140119828833d7eb2008d6b1d0cb890f163585b Mon Sep 17 00:00:00 2001 From: oslomp Date: Fri, 14 Dec 2018 23:23:46 +0100 Subject: [PATCH] Changed cache location for userstats. Settings needs to be added: 'userstats': { 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', 'LOCATION': '/var/tmp/MarietjeDjango_cache/default', 'OPTIONS': { 'MAX_ENTRIES': 1500 }, }, --- marietje/.gitignore | 1 + marietje/stats/utils.py | 4 ++-- marietje/stats/views.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/marietje/.gitignore b/marietje/.gitignore index 23527b2..d633baa 100644 --- a/marietje/.gitignore +++ b/marietje/.gitignore @@ -1,2 +1,3 @@ /.idea/ *.sqlite3 +settings.py \ No newline at end of file diff --git a/marietje/stats/utils.py b/marietje/stats/utils.py index a4cae4b..9cd17e7 100644 --- a/marietje/stats/utils.py +++ b/marietje/stats/utils.py @@ -23,8 +23,8 @@ def recache_user_stats(): for user in users: new_stats = user_stats(user['id']) cacheloc = 'userstats_{}'.format(user['id']) - caches['default'].delete(cacheloc) - caches['default'].set(cacheloc, new_stats, 48 * 3600) + caches['userstats'].delete(cacheloc) + caches['userstats'].set(cacheloc, new_stats, 48 * 3600) return new_stats def to_days(time): diff --git a/marietje/stats/views.py b/marietje/stats/views.py index 232de2a..c3acf33 100644 --- a/marietje/stats/views.py +++ b/marietje/stats/views.py @@ -20,7 +20,7 @@ def stats(request): return render(request, 'stats/stats.html', data, status=status) def user_stats(request): - stats = caches['default'].get('userstats_{}'.format(request.user.id)) + stats = caches['userstats'].get('userstats_{}'.format(request.user.id)) status = 503 current_age = None current_age_text = None