from django.core.cache import caches, DEFAULT_CACHE_ALIAS
cache = caches[DEFAULT_CACHE_ALIAS]
cache.set(cache_key, data, timeout)
data = cache.get(cache_key)
The timeout argument is optional and defaults to the timeout argument of the appropriate backend in the CACHES setting (explained above). It’s the number of seconds the value should be stored in the cache.