public async Task <Dictionary <TKey, TEntity> > GetMany(IEnumerable <TKey> keys, CancellationToken cancellationToken = default)
        {
            var tasks    = keys.Distinct().Select(key => TryGet(key, cancellationToken)).ToArray();
            var entities = await Task.WhenAll(tasks).ConfigureAwait(false);

            var result = new Dictionary <TKey, TEntity>();

            foreach (var entity in entities)
            {
                if (entity != null !)
                {
                    result.Add(KeyExtractor.Invoke(entity), entity);
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
 public IEnumerable <Key> ExtractKeys(T target)
 {
     return(KeyExtractor.Invoke(target));
 }
 public IReadOnlyCollection <Key> ExtractKeys(T target)
 {
     return(KeyExtractor.Invoke(target));
 }