public static T HGetOrSet <T>(this LocalCacheService cache, string hashId, string key, Func <T> getValueFunc) { var val = cache.HGet <T>(hashId, key); if (val == null) { val = getValueFunc(); cache.HSet(hashId, key, val); } return(val); }
public static T GetOrSet <T>(this LocalCacheService cache, string key, Func <T> getValueFunc, TimeSpan?expiry = null) { var val = cache.Get <T>(key); if (val == null) { val = getValueFunc(); cache.Set(key, val, expiry); } return(val); }