code: def get_redis_connection(config, use_strict_redis=False):
      
      redis_cls = redis.StrictRedis if use_strict_redis else redis.Redis
  
      if 'URL' in config:
          return redis_cls.from_url(config['URL'], db=config.get('DB'))
  
      if 'USE_REDIS_CACHE' in config.keys():
  
          try:
              # Assume that we're using django-redis
              from django_redis import get_redis_connection as get_redis
              return get_redis(config['USE_REDIS_CACHE'])
          except ImportError:
              pass
  
          from django.core.cache import caches
          cache = caches[config['USE_REDIS_CACHE']]
          # We're using django-redis-cache
          try:
              return cache._client
          except AttributeError:
              # For django-redis-cache > 0.13.1
              return cache.get_master_client()
  
      if 'UNIX_SOCKET_PATH' in config:
          return redis_cls(unix_socket_path=config['UNIX_SOCKET_PATH'], db=config['DB'])
  
      if 'SENTINELS' in config:
          sentinel_kwargs = {
              'db': config.get('DB'),
              'password': config.get('PASSWORD'),
              'socket_timeout': config.get('SOCKET_TIMEOUT'),
          }
          sentinel_kwargs.update(config.get('CONNECTION_KWARGS', {}))
          sentinel = Sentinel(config['SENTINELS'], **sentinel_kwargs)
          return sentinel.master_for(
              service_name=config['MASTER_NAME'], redis_class=redis_cls,
          )
  
      return redis_cls(host=config['HOST'], port=config['PORT'], db=config['DB'], password=config.get('PASSWORD'), ssl=config.get('SSL', False))
docs: Returns a redis connection from a connection config