Set all cache TTLs to 2 days

Fixes #15.
This commit is contained in:
Daan Sprenkels
2019-10-25 19:28:52 +02:00
parent ce3bfb02d5
commit d0ed0a0a62

View File

@ -10,10 +10,12 @@ from songs.models import Song
from marietje.models import User from marietje.models import User
CACHE_TTL = 2 * 24 * 3600
def recache_stats(): def recache_stats():
new_stats = compute_stats() new_stats = compute_stats()
caches['default'].delete('stats') caches['default'].delete('stats')
caches['default'].set('stats', new_stats, 2 * 3600) caches['default'].set('stats', new_stats, CACHE_TTL)
return new_stats return new_stats
@ -25,7 +27,7 @@ def recache_user_stats():
new_stats = user_stats(user['id']) new_stats = user_stats(user['id'])
cacheloc = 'userstats_{}'.format(user['id']) cacheloc = 'userstats_{}'.format(user['id'])
caches['userstats'].delete(cacheloc) caches['userstats'].delete(cacheloc)
caches['userstats'].set(cacheloc, new_stats, 48 * 3600) caches['userstats'].set(cacheloc, new_stats, CACHE_TTL)
return new_stats return new_stats