Skip to content

Instantly share code, notes, and snippets.

@rejwan
Created February 16, 2015 14:25
Show Gist options
  • Save rejwan/48ae36bc57b5a2deae32 to your computer and use it in GitHub Desktop.
Save rejwan/48ae36bc57b5a2deae32 to your computer and use it in GitHub Desktop.
public static async Task<Player> GetPlayerBySecretKey(string secretKey)
{
if (!ConfigurationManager.IsCacheEnabled || string.IsNullOrEmpty(secretKey))
{
return null;
}
try
{
ICacheClient redis = _redisPool.GetCacheClient();
using (redis)
{
var player = await Task.Run(() => redis.Get<Player>(GetFormattedPlayerId(secretKey)));
if (player != null)
{
player.IsTrackingChanges = true;
}
return player;
}
}
catch (Exception exception)
{
DebugAccess.WriteDebug(exception, "REDIS GET FAIL");
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment