This repository has been archived on 2026-10-23. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
nikolark d4f862cb4a Refactor alot
- add django-redis-cache
- remove CurrentTrack db model
2016-04-06 22:16:32 +02:00

22 lines
461 B
Python

from django.core.cache import cache
from oliver_screen.models import YouTubeVideo
def get_youtubevideo(artist, title):
videos = YouTubeVideo.objects.filter(artist=artist, title=title)
if len(videos) != 1:
# should only be one
return ""
return videos[0]
CACHE_KEY = 'oliver-track'
def cache_current(track):
return cache.set(CACHE_KEY, track, 20) # in seconds
def get_current_from_cache():
return cache.get(CACHE_KEY)