コード例 #1
0
def clean_all(cache):
    def _delete_nocheck(filename):
        return unlink(filename)

    find(cache.base_path, r'^.*\.dat$', _delete_nocheck)
    find(cache.base_path, r'^.*\.local$', _delete_nocheck)
    return True
コード例 #2
0
def clean_old(cache):
    def delete_one(filename):
        data = cache.load_from_store(filename)
        if not cache.check_magic(data):
            raise TypeError('magic mismatch')
        ttl = cache.is_fresh(data['key'], data)
        if ttl:
            return True
        cache.delete(data['key'])
        return True

    find(cache.base_path, '^.*\.dat$', delete_one)
    return True
コード例 #3
0
def clean_all(cache):
    """Clean all data from cache
    """
    def delete_one(filename, info):
        '''::callback that delete one file
        '''
        data = cache.load_from_store(filename)
        if not cache.check_magic(data):
            print "Error: bad magic, skipping file %s" % (filename)
            return True
        cache.delete(data['key'])
        return True
    find(cache.base_path, '^.*\.dat$', delete_one)
    return True