2022-01-08 15:59:56 -05:00
|
|
|
""" 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:
|
2022-01-09 15:16:01 -05:00
|
|
|
value = function(*args)
|
|
|
|
cache.set(cache_key, value, timeout=timeout)
|
|
|
|
return value
|