Add caching for song searching

This commit is contained in:
Daan Sprenkels
2018-08-16 23:32:20 +02:00
parent 641e5cb908
commit 2a340ef22c
4 changed files with 36 additions and 25 deletions

View File

@ -1,6 +1,6 @@
from datetime import datetime, timedelta
from django.core.cache import cache
from django.core.cache import caches
from django.conf import settings
from django.db.models import Count, Q
from django.shortcuts import render
@ -12,8 +12,8 @@ from songs.models import Song
def recache_stats():
new_stats = compute_stats()
cache.delete('stats')
cache.set('stats', new_stats, 7200)
caches['default'].delete('stats')
caches['default'].set('stats', new_stats, 7200)
return new_stats
def compute_stats():