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


C# IDatabase.SetMembers方法代码示例

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


在下文中一共展示了IDatabase.SetMembers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ReadAll

 public static IEnumerable<Command> ReadAll(IDatabase db)
 {
     var commands = db.SetMembers("Commands");
     foreach (var item in commands)
     {
         yield return Read(db, Guid.Parse(item));
     }
 }
开发者ID:wallymathieu,项目名称:redis-studies,代码行数:8,代码来源:AppendToRedis.cs

示例3: InvalidateSets

        public void InvalidateSets(IEnumerable<string> entitySets)
        {
            if (entitySets == null)
            {
                throw new ArgumentNullException("entitySets");
            }
            _database = _redis.GetDatabase();
            
            var itemsToInvalidate = new HashSet<string>();

            lock (_lock)
            {
                try 
                {
                    foreach (var entitySet in entitySets) {
                        var entitySetKey = GetEntitySetKey(entitySet);
                        var keys = _database.SetMembers(entitySetKey).Select(v => v.ToString());
                        itemsToInvalidate.UnionWith(keys);
                        _database.KeyDelete(EntitySetKey);
                    }
                } 
                catch (Exception e) 
                {
                    OnCachingFailed(e);
                    return;
                }

                foreach (var key in itemsToInvalidate)
                {
                    InvalidateItem(key);
                }
            }
        }
开发者ID:GlenConway,项目名称:EFCache.Redis,代码行数:33,代码来源:RedisCache.cs

示例4: InvalidateSets

        public void InvalidateSets(IEnumerable<string> entitySets)
        {
            // ReSharper disable once PossibleMultipleEnumeration - the guard clause should not enumerate, its just checking the reference is not null
            entitySets.GuardAgainstNull(nameof(entitySets));
            
            _database = _redis.GetDatabase();
            
            var itemsToInvalidate = new HashSet<string>();

            lock (_lock)
            {
                try 
                {
                    // ReSharper disable once PossibleMultipleEnumeration - the guard clause should not enumerate, its just checking the reference is not null
                    foreach (var entitySet in entitySets) {
                        var entitySetKey = AddCacheQualifier(entitySet);
                        var keys = _database.SetMembers(entitySetKey).Select(v => v.ToString());
                        itemsToInvalidate.UnionWith(keys);
                        _database.KeyDelete(entitySetKey, CommandFlags.FireAndForget);
                    }
                } 
                catch (Exception e) 
                {
                    OnCachingFailed(e);
                    return;
                }

                foreach (var key in itemsToInvalidate)
                {
                    InvalidateItem(key);
                }
            }
        }
开发者ID:silentbobbert,项目名称:EFCache.Redis,代码行数:33,代码来源:RedisCache.cs


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