def _prepare_cache(use_cache=True):
    'Prepare a private token serialization cache.\n\n    :param use_cache: boolean indicating whether a real cache should\n                      be used or not. If not, the returned functions\n                      are no-ops.\n\n    :return: emit and get functions, for storing and retrieving\n             serialized values from the cache.\n    '
    cache = {}
    if use_cache:

        def _emit(kind, input, output):
            cache[(kind, input)] = output
            return output
        _get = cache.get
    else:

        def _emit(kind, input, output):
            return output

        def _get(key):
            pass
    return (_emit, _get, cache)
Prepare a private token serialization cache.

:param use_cache: boolean indicating whether a real cache should
                  be used or not. If not, the returned functions
                  are no-ops.

:return: emit and get functions, for storing and retrieving
         serialized values from the cache.
def _prepare_cache(use_cache=True):
    'Prepare a private token serialization cache.\n\n    :param use_cache: boolean indicating whether a real cache should\n                      be used or not. If not, the returned functions\n                      are no-ops.\n\n    :return: emit and get functions, for storing and retrieving\n             serialized values from the cache.\n    '
    cache = {}
    if use_cache:

        def _emit(kind, input, output):
            cache[(kind, input)] = output
            return output
        _get = cache.get
    else:

        def _emit(kind, input, output):
            return output

        def _get(key):
            pass
    return (_emit, _get, cache)