There are 2 methods to get the redis connection when using django-redis (https://niwinz.github.io/django-redis/latest/) lib
method-1
from django.core.cache import caches
# get redis cache from settings
rcache = caches['redis']
method-2
from django_redis import get_redis_connection
rcache = get_redis_connection("redis")
my django settings look like this
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.memcached.MemcachedCache",
"LOCATION": MEMCACHED_URL,
"OPTIONS": {
'MAX_ENTRIES': 2000
}
},
"redis": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": REDIS_URL,
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient"
}
}
}
I tried checking internals and looks like get_redis_connection uses a connection pool, but the object it returns is of the strictredis client and not the default client - hence one cannot exactly jump from one to another.
That being said, can someone confirm which one to use if you want to use connection pool when using the django-redis library
Note: I am using memcache as the default django cache backend at present, with redis for some other caching purposes.
Please let me know if the question or description sounds confusing, i can update.