Raven.ManagedStorage.Degenerate.PersistentDictionary.Add C# (CSharp) Method

Add() public method

public Add ( JToken key, byte value, System.Guid txId ) : bool
key JToken
value byte
txId System.Guid
return bool
        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;
        }