当前位置: 首页>>代码示例>>C#>>正文


C# IRedisClient.SetEntryInHash方法代码示例

本文整理汇总了C#中IRedisClient.SetEntryInHash方法的典型用法代码示例。如果您正苦于以下问题:C# IRedisClient.SetEntryInHash方法的具体用法?C# IRedisClient.SetEntryInHash怎么用?C# IRedisClient.SetEntryInHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRedisClient的用法示例。


在下文中一共展示了IRedisClient.SetEntryInHash方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadDifferentKeyTypes

        protected void LoadDifferentKeyTypes(IRedisClient redis)
        {
            int A = 'A';
            int Z = 'Z';
            var letters = (Z - A + 1).Times(i => ((char)(i + A)).ToString());
            var numbers = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };

            redis.RemoveEntry("list:letters", "list:numbers"); //don't add duplicates to existing list
            letters.Each(x => redis.AddItemToList("list:letters", x));
            numbers.Each(x => redis.AddItemToList("list:numbers", x));

            letters.Each(x => redis.AddItemToSet("set:letters", x));
            numbers.Each(x => redis.AddItemToSet("set:numbers", x));

            var pos = 0;
            letters.Each(x => redis.AddItemToSortedSet("zset:letters", x, pos++));
            pos = 0;
            numbers.Each(x => redis.AddItemToSortedSet("zset:numbers", x, pos++));

            pos = 0;
            letters.Each(x => redis.SetEntryInHash("hash:letters", x, (pos++).ToString()));
            pos = 0;
            numbers.Each(x => redis.SetEntryInHash("hash:numbers", x, (pos++).ToString()));
        }
开发者ID:JerryForNet,项目名称:RedisAdminUI,代码行数:24,代码来源:PopulateRedisWithDataService.cs

示例2: RequeueJobIfTimedOut

        private bool RequeueJobIfTimedOut(IRedisClient redis, string jobId, string queue)
        {
            var flags = redis.GetValuesFromHash(
                String.Format("hangfire:job:{0}", jobId),
                "Fetched",
                "Checked");

            var fetched = flags[0];
            var @checked = flags[1];

            if (String.IsNullOrEmpty(fetched) && String.IsNullOrEmpty(@checked))
            {
                // If the job does not have these flags set, then it is
                // in the implicit 'Fetched' state. This state has no 
                // information about the time it was fetched. So we
                // can not do anything with the job in this state, because
                // there are two options:

                // 1. It is going to move to the implicit 'Fetched' state
                //    in a short time.
                // 2. It will stay in the 'Fetched' state forever due to
                //    its processing server is dead.

                // To ensure its server is dead, we'll move the job to
                // the implicit 'Checked' state with the current timestamp
                // and will not do anything else at this pass of the watcher.
                // If job's state will still be 'Checked' on the later passes
                // and after the CheckedTimeout expired, then the server
                // is dead, and we'll re-queue the job.

                redis.SetEntryInHash(
                    String.Format("hangfire:job:{0}", jobId),
                    "Checked",
                    JobHelper.ToStringTimestamp(DateTime.UtcNow));

                // Checkpoint #1-2. The job is in the implicit 'Checked' state.
                // It will be re-queued after the CheckedTimeout will be expired.
            }
            else
            {
                if (TimedOutByFetchedTime(fetched) || TimedOutByCheckedTime(fetched, @checked))
                {
                    var stateMachine = new StateMachine(new RedisConnection(_storage, redis));
                    var state = new EnqueuedState{
                        Reason = "Re-queued due to time out"
                    };

                    stateMachine.TryToChangeState(
                        jobId, 
                        state, 
                        new [] { EnqueuedState.StateName, ProcessingState.StateName });

                    RedisConnection.RemoveFromFetchedList(redis, queue, jobId);

                    return true;
                }
            }

            return false;
        }
开发者ID:hahmed,项目名称:HangFire,代码行数:60,代码来源:FetchedJobsWatcher.cs


注:本文中的IRedisClient.SetEntryInHash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。