18 lines
469 B
Python
18 lines
469 B
Python
from fwd_api.models import Caching
|
|
|
|
def set_cache(key, value):
|
|
cache = Caching.objects.filter(key=key)
|
|
if cache.count() == 0:
|
|
this_cache = Caching(key=key, value=value)
|
|
else:
|
|
this_cache = cache.first()
|
|
this_cache.value = value
|
|
this_cache.save()
|
|
return this_cache
|
|
|
|
def get_cache(key):
|
|
value = {}
|
|
cache = Caching.objects.filter(key=key)
|
|
if cache.count() > 0:
|
|
value = cache.first().value
|
|
return value |