<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def clear_cache(days=-1):
    '''
    Forcibly removes all caches on a minion.

    .. versionadded:: 2014.7.0

    WARNING: The safest way to clear a minion cache is by first stopping
    the minion and then deleting the cache files before restarting it.

    CLI Example:

    .. code-block:: bash

        salt '*' saltutil.clear_cache days=7
    '''
    threshold = time.time() - days * 24 * 60 * 60
    for root, dirs, files in salt.utils.files.safe_walk(__opts__['cachedir'], followlinks=False):
        for name in files:
            try:
                file = os.path.join(root, name)
                mtime = os.path.getmtime(file)
                if mtime < threshold:
                    os.remove(file)
            except OSError as exc:
                log.error(
                    'Attempt to clear cache with saltutil.clear_cache '
                    'FAILED with: %s', exc
                )
                return False
    return True