def METHOD_NAME(cacheDir, threshold, sleep=5, simulate=False, min_erase = 0):
    bytes = getbytesleft(cacheDir,threshold)
    if (bytes>0):
        print "Bytes to go before we hit threshold:", bytes
    else:
        print "Threshold exceeded with:", -bytes, "bytes"
        dir = os.listdir(cacheDir)
        dir2 = []
        for file in dir:
            path = cacheDir + '/' + file
            dir2.append({
                "path" : path,
                "atime": os.stat(path).st_atime,
                "size" : os.stat(path).st_size
            })
        dir2.sort(lambda x,y: int(x["atime"]-y["atime"]))
        filesunlinked = 0
        gainedspace = 0
        # Left is the amount of bytes that need to be freed up
        # The default is the 'min_erase setting'
        left = min_erase
        # If the min_erase setting is lower than the amount of bytes over
        # the threshold, we use that number instead.
        if left < -bytes :
            left = -bytes
        print "Need to delete at least:", left;
        for file in dir2:
            # Only deleting files if we're not simulating
            if not simulate: os.unlink(file["path"])
            left = int(left - file["size"])
            gainedspace = gainedspace + file["size"]
            filesunlinked = filesunlinked + 1
            if(left<0):
                break
        print "%d files deleted (%d bytes)" % (filesunlinked, gainedspace)
    time.sleep(sleep)