@contextmanager<EOL>def memcached_client(servers=config.memcached_uri, debug=config.debug_memcache):
key = None<EOL>try:<EOL><INDENT>client, key = scoped_instance_manager.acquire(servers, debug=debug)<EOL>yield client<EOL><DEDENT>finally:<EOL><INDENT>if key:<EOL><INDENT>scoped_instance_manager.release(key)<EOL><DEDENT><DEDENT>
Get a shared memcached instance.

    This function shares the same memcached instance across nested invocations.
    This is done so that memcached connections can be kept to a minimum, but at
    the same time unnecessary extra reconnections are avoided. Typically an
    initial scope (using 'with' construct) is made around parts of code that hit
    the cache server many times - such as a resolve, or executing a context. On
    exit of the topmost scope, the memcached client is disconnected.

    Returns:
        `Client`: Memcached instance.