本文整理汇总了C#中IDatabase.HashSet方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabase.HashSet方法的具体用法?C# IDatabase.HashSet怎么用?C# IDatabase.HashSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase.HashSet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: PushTask
public static void PushTask(IDatabase db, string task)
{
db.HashSet("task-" + task, new[] { new HashEntry("submitted", DateTime.Now.ToString("dd/MM/yy HH:mm:ss.fff")) });
db.ListLeftPush("submitted", task);
db.Publish("submittedTask", "");
Console.WriteLine("pushed: " + task);
}
示例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;
}
示例4: InitValues
private static void InitValues(IDatabase db)
{
var saldo = 0;
for( var i = 1; i < 10; ++i )
{
var betrag = rnd.Next(MAX_BETRAG) - (MAX_BETRAG/2);
saldo += betrag;
db.HashSet(keyTest + i.ToString(), "saldo", betrag);
db.HashSet(keyTest + i.ToString(), "nummer", i);
}
db.HashSet(keyTest + 0.ToString(), "saldo", -saldo);
db.HashSet(keyTest + 0.ToString(), "nummer", 0);
}
示例5: Save
public override bool Save(object obj,
Type objType,
IDatabase redisDatabase,
string id,
PropertyInfo basePropertyInfo = null)
{
var redisKey = new RedisKeyObject(objType, id);
CommonData data = null;
if (obj is IProxyTargetAccessor)
{
data = ((IProxyTargetAccessor) obj).GetCommonData();
data.Processing = true;
}
var hashList = RedisObjectManager.ConvertToRedisHash(obj).ToArray();
if (data != null)
{
data.Processing = false;
}
RedisObjectManager.RedisBackup?.UpdateHash(hashList, redisKey);
RedisObjectManager.RedisBackup?.RestoreHash(redisDatabase, redisKey);
redisDatabase.HashSet(redisKey.RedisKey, hashList);
return true;
}