Last active
April 19, 2016 13:58
-
-
Save timgabrhel/17e8d888285d71b670fbb85924b8aecd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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