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


C# IDatabase.SetAdd方法代码示例

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


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

示例1: CompleteTask

        public static void CompleteTask(IDatabase db, string task)
        {
            db.SetRemove("running", task);
            db.HashSet("task-" + task, new[] { new HashEntry("complete", DateTime.Now.ToString("dd/MM/yy HH:mm:ss.fff")) });
            db.SetAdd("complete", task);

            var workflow = db.HashGet("task-" + task, "workflow");
            var remaining = db.HashDecrement("workflow-" + workflow, "tasksRemaining");
            if (remaining.Equals(0))
            {
                db.Publish("workflowComplete", workflow);

                return;
            }

            var children = db.SetMembers("children-" + task);
            foreach (var child in children)
            {
                db.SetRemove("parents-" + child, task);
                if (db.SetLength("parents-" + child).Equals(0))
                {
                    Direct.PushTask(db, child);
                }
            }

            Console.WriteLine("completed: " + task);
        }
开发者ID:Timxuhj,项目名称:redis.workflow,代码行数:27,代码来源:Direct.cs

示例2: GetWorkflowId

        public static long GetWorkflowId(IDatabase db)
        {
            if (db.SetLength("workflowIds").Equals(0))
            {
                var tempId = db.HashIncrement("ids", "currentWorkflowId");
                db.SetAdd("workflowIds", tempId);
            }

            var workflowId = (long)db.SetPop("workflowIds");

            return workflowId;
        }
开发者ID:Timxuhj,项目名称:redis.workflow,代码行数:12,代码来源:Direct.cs

示例3: PopTask

        public static string PopTask(IDatabase db)
        {
            var task = db.ListRightPop("submitted");

            if (task.Equals(RedisValue.Null)) return null;

            db.SetAdd("running", task);
            db.HashSet("task-" + task, new[] { new HashEntry("running", DateTime.Now.ToString("dd/MM/yy HH:mm:ss.fff")) });

            Console.WriteLine("popped: " + task);

            return task;
        }
开发者ID:Timxuhj,项目名称:redis.workflow,代码行数:13,代码来源:Direct.cs

示例4: CheckSetContent

 private static void CheckSetContent(IDatabase db, List<string> expected, string state, bool condition = true)
 {
     var toRequeue = new List<string>();
     while (db.SetLength(state) != 0)
     {
         toRequeue.Add(db.SetPop(state));
     }
     foreach (var item in expected)
     {
         if(condition)
             Assert.IsTrue(toRequeue.Contains(item));
         else
             Assert.IsFalse(toRequeue.Contains(item));
     }
     foreach (var temp in toRequeue)
     {
         db.SetAdd(state, temp);
     }
 }
开发者ID:timbarrass,项目名称:redis.workflow,代码行数:19,代码来源:BasicWorkflowTests.cs

示例5: PutItem

        public void PutItem(string key, object value, IEnumerable<string> dependentEntitySets, TimeSpan slidingExpiration, DateTimeOffset absoluteExpiration)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            if (dependentEntitySets == null)
            {
                throw new ArgumentNullException("dependentEntitySets");
            }
            _database = _redis.GetDatabase();
            
            key = HashKey(key);
            var entitySets = dependentEntitySets.ToArray();

            lock (_lock)
            {
                try 
                {
                    _database.Set(key, new CacheEntry(value, entitySets, slidingExpiration, absoluteExpiration));
                    foreach (var entitySet in entitySets) {
                        _database.SetAdd(GetEntitySetKey(entitySet), key);
                    }
                } 
                catch (Exception e) 
                {
                    OnCachingFailed(e);
                }
            }
        }
开发者ID:GlenConway,项目名称:EFCache.Redis,代码行数:31,代码来源:RedisCache.cs

示例6: PutItem

        public void PutItem(string key, object value, IEnumerable<string> dependentEntitySets, TimeSpan slidingExpiration, DateTimeOffset absoluteExpiration)
        {
            key.GuardAgainstNullOrEmpty(nameof(key));
            // ReSharper disable once PossibleMultipleEnumeration - the guard clause should not enumerate, its just checking the reference is not null
            dependentEntitySets.GuardAgainstNull(nameof(dependentEntitySets));
           
            _database = _redis.GetDatabase();
            
            key = HashKey(key);
            // ReSharper disable once PossibleMultipleEnumeration - the guard clause should not enumerate, its just checking the reference is not null
            var entitySets = dependentEntitySets.ToArray();

            lock (_lock)
            {
                try 
                {
                    foreach (var entitySet in entitySets)
                    {
                        _database.SetAdd(AddCacheQualifier(entitySet), key, CommandFlags.FireAndForget);
                    }

                    _database.Set(key, new CacheEntry(value, entitySets, slidingExpiration, absoluteExpiration));
                } 
                catch (Exception e) 
                {
                    OnCachingFailed(e);
                }
            }
        }
开发者ID:silentbobbert,项目名称:EFCache.Redis,代码行数:29,代码来源:RedisCache.cs


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