本文整理汇总了C#中BookSleeve.RedisConnection.Increment方法的典型用法代码示例。如果您正苦于以下问题:C# RedisConnection.Increment方法的具体用法?C# RedisConnection.Increment怎么用?C# RedisConnection.Increment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BookSleeve.RedisConnection
的用法示例。
在下文中一共展示了RedisConnection.Increment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsyncRedisUsage
// could also be void; only a Task here so I can Wait on
// completion from my Main method, which is not declared
// as async
async static Task AsyncRedisUsage()
{
const int db = 4; // no reason
using(var conn = new RedisConnection("127.0.0.1"))
{
// let's wait until all handshakes have happened
await conn.Open();
var existed = conn.Remove(db, "some-key");
for (int i = 0; i < 100; i++)
{ // this are also tasks, but I don't
// need to wait on them in this case
conn.Increment(db, "some-key");
}
// at this point, some messages are flying around
// from a background queue, with responses being
// handled by IOCP; let's add a GET onto the
// bottom of the queue, and let other stuff
// happen until we have the answer (obviously
// we could make much more subtle use here, by
// awaiting multiple things requested much earlier,
// or by doing some SQL Server work etc before
// calling await, essentially acting as a "join")
string result = await conn.GetString(db, "some-key");
Console.WriteLine(await existed
? "(it already existed; we removed it)"
: "(it didn't exist)");
Console.WriteLine(result);
}
}