def get_cached(factory, cache_file_name, **kwargs):
    """
    Loads cache if exists, otherwise calls factory and stores the results in the specified cache file.
    **kwargs are passed to the serialize() function
    :param factory:
    :param cache_file_name:
    :return:
    """
    if os.path.exists(cache_file_name):
        _logger.info('Loading {}'.format(cache_file_name))
        cached = deserialize(cache_file_name)
        return cached

    _logger.info('Creating {}'.format(cache_file_name))
    data = factory()
    serialize(cache_file_name, data, **kwargs)
    return data

    Loads cache if exists, otherwise calls factory and stores the results in the specified cache file.
    **kwargs are passed to the serialize() function
    :param factory:
    :param cache_file_name:
    :return:
    
cakechat/utils/files_utils.py