moviewyrm/bookwyrm/utils/cache.py
2022-01-09 12:16:01 -08:00

11 lines
344 B
Python

""" Custom handler for caching """
from django.core.cache import cache
def get_or_set(cache_key, function, *args, timeout=None):
"""Django's built-in get_or_set isn't cutting it"""
value = cache.get(cache_key)
if value is None:
value = function(*args)
cache.set(cache_key, value, timeout=timeout)
return value