def get_redis_connection(config, use_strict_redis=False):
redis_cls = redis.StrictRedis if use_strict_redis else redis.Redis<EOL>if '<STR_LIT>' in config:<EOL><INDENT>return redis_cls.from_url(config['<STR_LIT>'], db=config.get('<STR_LIT>'))<EOL><DEDENT>if '<STR_LIT>' in config.keys():<EOL><INDENT>try:<EOL><INDENT>from django_redis import get_redis_connection as get_redis<EOL>return get_redis(config['<STR_LIT>'])<EOL><DEDENT>except ImportError:<EOL><INDENT>pass<EOL><DEDENT>from django.core.cache import caches<EOL>cache = caches[config['<STR_LIT>']]<EOL>try:<EOL><INDENT>return cache._client<EOL><DEDENT>except AttributeError:<EOL><INDENT>return cache.get_master_client()<EOL><DEDENT><DEDENT>if '<STR_LIT>' in config:<EOL><INDENT>return redis_cls(unix_socket_path=config['<STR_LIT>'], db=config['<STR_LIT>'])<EOL><DEDENT>if '<STR_LIT>' in config:<EOL><INDENT>sentinel_kwargs = {<EOL>'<STR_LIT>': config.get('<STR_LIT>'),<EOL>'<STR_LIT:password>': config.get('<STR_LIT>'),<EOL>'<STR_LIT>': config.get('<STR_LIT>'),<EOL>}<EOL>sentinel_kwargs.update(config.get('<STR_LIT>', {}))<EOL>sentinel = Sentinel(config['<STR_LIT>'], **sentinel_kwargs)<EOL>return sentinel.master_for(<EOL>service_name=config['<STR_LIT>'], redis_class=redis_cls,<EOL>)<EOL><DEDENT>return redis_cls(host=config['<STR_LIT>'], port=config['<STR_LIT>'], db=config['<STR_LIT>'], password=config.get('<STR_LIT>'), ssl=config.get('<STR_LIT>', False))<EOL>
Returns a redis connection from a connection config