public bool Add(JToken key, byte[] value, Guid txId)
{
Guid existing;
if (keysModifiedInTx.TryGetValue(key, out existing) && existing != txId)
return false;
long position;
lock (persistentSource.SyncLock)
{
// we *always* write to the end
position = persistentSource.Data.Position = persistentSource.Data.Length;
persistentSource.Data.Write(value, 0, value.Length);
}
operationsInTransactions.GetOrAdd(txId, new List<Command>())
.Add(new Command
{
Key = key,
Position = position,
Size = value.Length,
DictionaryId = DictionaryId,
Type = CommandType.Put
});
if (existing != txId) // otherwise we are already there
keysModifiedInTx.TryAdd(key, txId);
return true;
}