示例#1
0
void LogCache::DeleteOldRounds(uint64_t paxosID)
{
	Cursor			cursor;
	ByteArray<128>	buf;
	DynArray<128>	key;
	DynArray<128>	value;
	Transaction*	transaction;
	
	transaction = RLOG->GetTransaction();
	
	transaction->Begin();
	
	WriteRoundID(buf, paxosID);
	table->Iterate(transaction, cursor);
	if (!cursor.Start(buf))
	{
		cursor.Close();
		transaction->Rollback();
		return;
	}
		
	while (cursor.Prev(key, value))
	{
		if (key.length > sizeof("@@pround:") - 1 &&
		strncmp(key.buffer, "@@pround:", sizeof("@@pround:") - 1) == 0)
			cursor.Delete();
		else
			break;
	}
	
	cursor.Close();

	transaction->Commit();
}