Return a new :class:`FsCache` built on the configured cache directory

def new_cache(config, root_dir='no_root_dir'):
    """Return a new :class:`FsCache` built on the configured cache directory
    """

    if isinstance(config, basestring):
        config = parse_cache_string(config, root_dir)

    if 'size' in config:
        from filesystem import FsLimitedCache
        fsclass = FsLimitedCache

    elif 'bucket' in config:
        from s3 import S3Cache
        fsclass = S3Cache

    elif 'url' in config:
        from http import HttpCache
        fsclass = HttpCache

    elif 'dir' in config:
        from filesystem import FsCache
        fsclass = FsCache

    else:
        raise ConfigurationError(
            "Can't determine cache type: {} ".format(config))

    # Re-write account to get login credentials, if the run_config is available
    if 'account' in config and isinstance(config['account'], basestring):

        acts = accounts()

        if not config['account'] in acts:
            raise ConfigurationError(
                "Accounts dict does not include account '{}': {} " .format(
                    config['account'],
                    acts))

        config['account'] = acts[config['account']]

    if 'upstream' in config:
        config['upstream'] = new_cache(config['upstream'], root_dir=root_dir)

    if 'options' in config:
        options = config['options']
    else:
        options = []

    cache = fsclass(**dict(config))

    if 'compress' in options:
        from filesystem import FsCompressionCache
        cache = FsCompressionCache(upstream=cache)

    if 'async' in options:
        from async import ThreadedWriteCache
        cache = ThreadedWriteCache(upstream=cache)

    if 'log' in options:
        from async import LoggingCache
        cache = LoggingCache(upstream=cache)

    return cache