本文整理汇总了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);
}
示例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));
}
}
示例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);
}
}
}
示例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);
}
}
}