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 },
    },
This commit is contained in:
oslomp
2018-12-14 23:23:46 +01:00
parent d99f12491c
commit 0140119828
3 changed files with 4 additions and 3 deletions

1
marietje/.gitignore vendored
View File

@ -1,2 +1,3 @@
/.idea/
*.sqlite3
settings.py

View File

@ -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):

View File

@ -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