有状态服务:可靠的字典:GET调用:asyncEnumerator.MoveNextAsync [英] Stateful Service: Reliable Dictionary: GET Call: asyncEnumerator.MoveNextAsync

查看:89
本文介绍了有状态服务:可靠的字典:GET调用:asyncEnumerator.MoveNextAsync的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

是否有一种直接从服务读取而不是使用MoveNextAsync进行迭代的方法.

Is there a way out to read directly from service instead of iterate using MoveNextAsync.

处理时间很长> 50000条记录.

It is taking long time to process > 50000 records.

使用(var tx = StateManager.CreateTransaction())

            {
                var queue =等待StateManager.GetOrAddAsync< IReliableDictionary< Guid,T>>>(_ cacheName);
                var items = await queue.CreateEnumerableAsync(tx);
               使用(var asyncEnumerator = items.GetAsyncEnumerator())
                {
                   一会儿(等待asyncEnumerator.MoveNextAsync(CancellationToken.None))
                    {
                       如果(asyncEnumerator.Current.Key.ToString().StartsWith(startWithKey))
                            itemList.Add(asyncEnumerator.Current.Value);
                    }
                }
               返回itemList;
            }

            {
                var queue = await StateManager.GetOrAddAsync<IReliableDictionary<Guid, T>>(_cacheName);
                var items = await queue.CreateEnumerableAsync(tx);
                using (var asyncEnumerator = items.GetAsyncEnumerator())
                {
                    while (await asyncEnumerator.MoveNextAsync(CancellationToken.None))
                    {
                        if (asyncEnumerator.Current.Key.ToString().StartsWith(startWithKey))
                            itemList.Add(asyncEnumerator.Current.Value);
                    }
                }
                return itemList;
            }

Ajay

推荐答案

Ajay.您能否提供更多有关您的设置和配置的背景信息,以便我提供更好的帮助?

Hi Ajay. Can you provide a bit more background information about your setup and configuration so I can better assist? 

是花了这么长时间还是新的东西?

Has it always taken this long or is this something new? 


这篇关于有状态服务:可靠的字典:GET调用:asyncEnumerator.MoveNextAsync的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆