public static void SetCache <T> (String key, T obj) { if (cache == null) { cache = RedisCacheExtension.Connection.GetDatabase(); } cache.StringSet(key, RedisCacheExtension.Serialize <T>(obj)); }
public static T GetCache <T>(String key, Func <T> missedFetchObj) { if (cache == null) { cache = RedisCacheExtension.Connection.GetDatabase(); } byte[] cachedItem = cache.StringGet(key); T obj = RedisCacheExtension.Deserialize <T>(cachedItem); if (obj == null) { obj = missedFetchObj(); SetCache <T>(key, obj); } return(obj); }