0

I found cache.close() saying below in the doc. *I'm learning Django Cache:

You can close the connection to your cache with close() if implemented by the cache backend.

So, I use cache.close() after I finish using cache in Django Views as shown below:

# "views.py"

from django.core.cache import cache

def test(request):
    cache.set("name", "John")
    cache.set("age", 36)

    print(cache.get("first_name")) # John
    print(cache.get("age")) # 36
    
    cache.close() # Here

    return HttpResponse("Test")

My questions:

  1. Is it needed to use cache.close() after finishing using cache in Django Views?
  2. If cache.close() is not used after finishing using cache in Django Views, are there anything bad?
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129

0 Answers0