Skip to content

Instantly share code, notes, and snippets.

@timgabrhel
Last active April 19, 2016 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timgabrhel/17e8d888285d71b670fbb85924b8aecd to your computer and use it in GitHub Desktop.
Save timgabrhel/17e8d888285d71b670fbb85924b8aecd to your computer and use it in GitHub Desktop.
private static Lazy<ConnectionMultiplexer> lazyConnection = new Lazy<ConnectionMultiplexer>(() =>
{
return ConnectionMultiplexer.Connect("{redis connection string}");
});
public static ConnectionMultiplexer Connection => lazyConnection.Value;
private static IDatabase Cache => Connection.GetDatabase();
private T getCacheObj<T>(string key)
{
return AttemptCacheCall(delegate
{
var json = Cache.StringGet(key);
return JsonConvert.DeserializeObject<T>(json);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment