def init_app(self, app, config_prefix=None):
        if 'redis' not in app.extensions:
            app.extensions['redis'] = {}
        self.config_prefix = config_prefix = config_prefix or 'REDIS'
        if config_prefix in app.extensions['redis']:
            raise ValueError('Already registered config prefix {0!r}.'.
                             format(config_prefix))
        converters = {'port': int}
        convert = lambda arg, value: (converters[arg](value)
                                      if arg in converters
                                      else value)
        key = lambda param: '{0}_{1}'.format(config_prefix, param)
        klass = app.config.get(key('CLASS'), RedisClass)
        if isinstance(klass, string_types):
            klass = import_string(klass)
        url = app.config.get(key('URL'))
        if url:
            urlparse.uses_netloc.append('redis')
            url = urlparse.urlparse(url)
            app.config[key('HOST')] = url.hostname
            app.config[key('PORT')] = url.port or 6379
            app.config[key('USER')] = url.username
            app.config[key('PASSWORD')] = url.password
            db = url.path.replace('/', '')
            app.config[key('DB')] = db if db.isdigit() else None
        host = app.config.get(key('HOST'))
        if host and (host.startswith('file://') or host.startswith('/')):
            app.config.pop(key('HOST'))
            app.config[key('UNIX_SOCKET_PATH')] = host
        args = self._build_connection_args(klass)
        kwargs = dict([(arg, convert(arg, app.config[key(arg.upper())]))
                       for arg in args
                       if key(arg.upper()) in app.config])
        connection = klass(**kwargs)
        app.extensions['redis'][config_prefix] = connection
        self._include_public_methods(connection)