code: def parse_url(url):
      
      parsed = urlparse(url)
      kwargs = parse_qsl(parsed.query)
  
      # TCP redis connection
      if parsed.scheme == 'redis':
          details = {'host': parsed.hostname}
          if parsed.port:
              details['port'] = parsed.port
          if parsed.password:
              details['password'] = parsed.password
          db = parsed.path.lstrip('/')
          if db and db.isdigit():
              details['db'] = db
  
      # Unix socket redis connection
      elif parsed.scheme == 'redis+socket':
          details = {'unix_socket_path': parsed.path}
      else:
          raise ValueError('Unsupported protocol %s' % (parsed.scheme))
  
      # Add kwargs to the details and convert them to the appropriate type, if needed
      details.update(kwargs)
      if 'socket_timeout' in details:
          details['socket_timeout'] = float(details['socket_timeout'])
      if 'db' in details:
          details['db'] = int(details['db'])
  
      return details
docs: Parse the argument url and return a redis connection.
      Two patterns of url are supported:
          * redis://host:port[/db][?options]
          * redis+socket:///path/to/redis.sock[?options]
      A ValueError is raised if the URL is not recognized.