本文整理汇总了C#中Bucket.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Bucket.Get方法的具体用法?C# Bucket.Get怎么用?C# Bucket.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bucket
的用法示例。
在下文中一共展示了Bucket.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetAndGetKetchupSync
public static double SetAndGetKetchupSync(int numberOfOperations, Bucket cli)
{
var start = DateTime.Now;
for (var i = 0; i < numberOfOperations; i++)
{
var key = "kc" + i;
var value = key + " value";
cli.Set(key, value);
}
for (var i = 0; i < numberOfOperations; i++)
{
var key = "kc" + i;
var expected = key + " value";
var actual = cli.Get<string>(key);
if (actual != expected) Console.WriteLine("Values did not match. expected: " + expected + ". actual: " + actual);
}
return (DateTime.Now - start).TotalSeconds;
}
示例2: SetAndGetKetchupAsync
public static double SetAndGetKetchupAsync(int numberOfOperations, Bucket cli)
{
var counter = numberOfOperations;
var start = DateTime.Now;
var sync = new object();
//simulate synchronous operation
TestAsync(180, (success, fail) =>
{
for (var i = 0; i < numberOfOperations; i++)
{
var key = "kc" + i;
var value = key + " value";
var bucket = "default";
object asyncState = new DemoAsyncState { Key = key };
cli.Set(key, value, s =>
{
lock (sync)
{
dynamic state = s;
var c = --counter;
if (debugAsync) Console.WriteLine(c + ": " + state.Key + ": set");
if (c == 0) success(s);
}
}, fail, asyncState);
}
});
counter = numberOfOperations;
TestAsync(60, (success, fail) =>
{
for (var i = 0; i < numberOfOperations; i++)
{
var key = "kc" + i;
var bucket = "default";
//get is fired on success return of set
var asyncState = new DemoAsyncState { Key = key, Counter = counter };
cli.Get<string>(key,
(val, s) =>
{
lock (sync)
{
dynamic state = s;
var c = --counter;
if (debugAsync) Console.WriteLine(c + ": " + state.Key + ": " + val);
if (c == 0) success(s);
}
},
s1 =>
{
lock (sync)
{
dynamic state1 = s1;
var c1 = --counter;
if (debugAsync) Console.WriteLine(c1 + ": " + state1.Key + ": miss");
if (c1 == 0) success(s1);
}
},
fail, asyncState
);
}
});
return (DateTime.Now - start).TotalSeconds;
}
示例3: RetrievePlayerInformation
// Retrieves the player information
IEnumerator RetrievePlayerInformation(uLink.NetworkPlayer networkPlayer, string accountId)
{
LogManager.General.Log("Retrieving player information for account " + accountId);
var bucket = new Bucket("AccountToName");
var request = bucket.Get(accountId);
yield return request.WaitUntilDone();
if(request.isSuccessful) {
string playerName = request.GetValue<string>();
LogManager.General.Log("Queried player name of '" + accountId + "' successfully: " + playerName);
// Retrieve stats
var statsBucket = new Bucket("AccountToStats");
var statsRequest = statsBucket.Get(accountId);
yield return statsRequest.WaitUntilDone();
PlayerStats statsInDB;
if(statsRequest.isSuccessful) {
statsInDB = statsRequest.GetValue<PlayerStats>();
LogManager.General.Log("Queried stats of account '" + accountId + "' successfully (Ranking: " + statsInDB.bestRanking + ")");
} else {
statsInDB = new PlayerStats();
LogManager.General.Log("Account '" + accountId + "' aka player '" + playerName + "' doesn't have any player stats yet");
}
// After we got the name, instantiate it
InstantiatePlayer(networkPlayer, accountId, playerName, statsInDB);
} else {
LogManager.General.LogWarning("Account " + accountId + " doesn't have a player name.");
}
}