Exemple #1
0
        /// <inheritdoc />
        public IEnumerable <ITaskProcessorRuntimeInfo> GetAll()
        {
            IEnumerable <string> entityIds = this.provider.GetSet(RedisTaskProcessorRuntimeInfoRepository.EntitySetKey);

            List <ITaskProcessorRuntimeInfo> result = new List <ITaskProcessorRuntimeInfo>();

            using (IRedisPipeline pipeline = this.provider.CreatePipeline())
            {
                foreach (string entityId in entityIds)
                {
                    string entityKey = RedisTaskProcessorRuntimeInfoRepository.GetEntityKey(entityId);

                    pipeline.GetHash(entityKey, values =>
                    {
                        if (values.Count > 0)
                        {
                            result.Add(RedisTaskProcessorRuntimeInfoRepository.Convert(values));
                        }
                    });
                }

                pipeline.Flush();
            }

            return(result);
        }
        private Dictionary <TaskStatus, IEnumerable <ITaskRuntimeInfo> > GetAllByType(params string[] listKeys)
        {
            List <string> entityIds = new List <string>();

            using (IRedisPipeline pipeline = this.provider.CreatePipeline())
            {
                foreach (string listKey in listKeys)
                {
                    pipeline.GetList(listKey, values => entityIds.AddRange(values));
                }

                pipeline.Flush();
            }

            Dictionary <TaskStatus, IEnumerable <ITaskRuntimeInfo> > result = new Dictionary <TaskStatus, IEnumerable <ITaskRuntimeInfo> >();

            using (IRedisPipeline pipeline = this.provider.CreatePipeline())
            {
                foreach (string entityId in entityIds)
                {
                    string entityKey = RedisTaskRuntimeInfoRepository.GetEntityKey(entityId);

                    pipeline.GetHash(entityKey, values =>
                    {
                        if (values.Count > 0)
                        {
                            ITaskRuntimeInfo taskInfo = RedisTaskRuntimeInfoRepository.Convert(values);

                            IEnumerable <ITaskRuntimeInfo> collection;

                            if (!result.TryGetValue(taskInfo.Status, out collection))
                            {
                                collection = new List <ITaskRuntimeInfo>();

                                result.Add(taskInfo.Status, collection);
                            }

                            ((ICollection <ITaskRuntimeInfo>)collection).Add(taskInfo);
                        }
                    });
                }

                pipeline.Flush();
            }

            return(result);
        }