本文整理汇总了C#中IDatabase.SetLength方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabase.SetLength方法的具体用法?C# IDatabase.SetLength怎么用?C# IDatabase.SetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase.SetLength方法的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: 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;
}
示例3: 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);
}
}
示例4: CreateQueueLengthSampler
private static void CreateQueueLengthSampler(List<Tuple<DateTime, string>> submittedQueueLength, List<Tuple<DateTime, string>> runningSetLength, IDatabase db)
{
var queueSampler = new System.Timers.Timer() { Interval = 10000, AutoReset = true, Enabled = true };
queueSampler.Elapsed += (s, e) =>
{
var val = db.SortedSetLength("submitted");
submittedQueueLength.Add(new Tuple<DateTime, string>(DateTime.Now, val.ToString()));
val = db.SetLength("running");
runningSetLength.Add(new Tuple<DateTime, string>(DateTime.Now, val.ToString()));
};
}