def init_app(self, app, conf_key=None):
        """
        :type app: flask.Flask
        :parm str conf_key: Key of flask config.
        """
        conf_key = conf_key or self.conf_key or 'PYMEMCACHE'
        self.conf_key = conf_key
        conf = app.config[conf_key]
        if not isinstance(conf, dict):
            raise TypeError("Flask-PyMemcache conf should be dict")

        close_on_teardown = conf.pop('close_on_teardown', False)

        if isinstance(conf['server'], list):
            conf['servers'] = conf.pop('server')
            client = pymemcache.client.hash.HashClient(**conf)
        elif isinstance(conf['server'], tuple):
            client = pymemcache.client.Client(**conf)
        else:
            raise TypeError("Flask-PyMemcache conf['server'] should be tuple or list of tuples")

        app.extensions.setdefault('pymemcache', {})
        app.extensions['pymemcache'][self] = client

        if close_on_teardown:
            @app.teardown_appcontext
            def close_connection(exc=None):
                client.close()