1

Consider the following code snippet:

from django.core.cache import cache

cache.delete('key_1')
cache.delete('key_2')

If i'm using an Instance of Redis as my default cache, will Django create two seperate connections to the Redis instance, for each call to .delete()? or will it keep a single connection open to fulfil both calls to .delete()?

I have a circumstance where I may need to delete a lot of individual keys in one go.

Ideally I would like a single connection to the Redis cache to persist, rather than take on the latency of creating a new connection each time a cache method is called.

Thanks

Scratcha
  • 1,359
  • 1
  • 14
  • 22
  • From a quick read through the documentation, it seems Redis maintains a connection pool that's used. You could verify this by using Redis' `CLIENT LIST` command to see connected clients and see how/if the connection change. – Carcigenicate Mar 12 '23 at 23:03

0 Answers0