def save_paste(source_id, data, expiration):
    """Let's save this stuff somewhere, find an available doc and update it."""
    global _timestamp, _timestamp_count

    # Clumsy flood management
    now = int(time.time())
    if _timestamp != now:
        _timestamp = now
        _timestamp_count = 1
    else:
        _timestamp_count += 1

    if _timestamp_count > 10:
        raise TooManySaves()

    doc = get_available_doc()
    new_doc = doc.copy()
    new_doc["raw"] = data
    new_doc["source"] = source_id
    new_doc["new"] = False
    # Keep it two weeks by default
    new_doc["expires"] = int(time.time() + expiration)
    try:
        _db.save(new_doc)
    except ResourceConflict:
        return save_paste(id, data, expiration)
    id = int(doc.id)
    _cache.append(new_doc)
    while len(_cache) > 50:
        _cache.pop(0)
    return id
dataset/ETHPy150Open tamentis/vimpaste/vimpaste/db.py/save_paste/original