Merge branch 'dsprenkels/issue_15' into 'marietje-zuid'

Set all cache TTLs to 2 days

Closes #15

See merge request dsprenkels/MarietjeDjango!39
This commit is contained in:
Olaf Slomp
2019-10-25 19:35:59 +02:00

View File

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