title: Django cache get expired entry
body: <p>In my views, I have the following</p>
  
  <pre><code>@require_POST
  def loadVals(request):
    result = //do some heavy calculations
    return HttpResponse(json.dumps({"data": result}), content_type="application/json")
  </code></pre>
  
  <p>Now I have added a cache so that I do not have to perform "heavy calclations" all the time. So the new code looks like</p>
  
  <p>settings.py</p>
  
  <pre><code>CACHES = {
  'default': {
      'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
      'LOCATION': 'unique-snowflake'
  }
  </code></pre>
  
  <p>}</p>
  
  <p>views.py</p>
  
  <pre><code>from django.core.cache import get_cache
  
  @require_POST
  def loadVals(request):
    cache = get_cache('default')
    result = cache.get('res')
    if result == NONE:
      result = //do some heavy calculations
      cache.set('res', result, 30)
      return HttpResponse(json.dumps({"data": result}), content_type="application/json")
    else:
      return HttpResponse(json.dumps({"data": result}), content_type="application/json") 
  </code></pre>
  
  <p>What I want to do instead is that even if that cache has expired, I want to save the front end user some wait time(because of heavy calculations) and just return the last expired value.
  And then refresh the cache.</p>
  
  <p>How do I </p>
  
  <p>1) get the value of expired cache? because cache.get('res') return NONE if cache has expired</p>
  
  <p>2) make a call after the return HttpResponse statement to refresh the cache value and do heavy calculations( where return statmenet just returned the expired value) OR may be do this via asynchronous calls?</p>