Ejemplo n.º 1
0
        public async Task <TValue> GetOrAddAsync(ITransaction tx, TKey key, Func <TKey, TValue> valueFactory, TimeSpan timeout, CancellationToken cancellationToken)
        {
            bool   isAdd = false;
            TValue value = default(TValue);

            var result = await _dictionary.GetOrAddAsync(tx, key, k => { isAdd = true; value = valueFactory(k); return(value); }, timeout, cancellationToken).ConfigureAwait(false);

            if (isAdd)
            {
                await OnAddAsync(tx, key, value, timeout, cancellationToken).ConfigureAwait(false);
            }

            return(result);
        }
 private Task <ReliableListMetaData> GetMetadataAsync(ITransaction tx, string key) =>
 _metadataStore.GetOrAddAsync(tx, MakeMetadataKey(key), _ => new ReliableListMetaData());