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
public static class CacheHelper | |
{ | |
private static readonly Object _locker = new object(); | |
public static T GetCacheItem<T>(String key, Func<T> cachePopulate, TimeSpan? slidingExpiration = null, DateTime? absoluteExpiration = null) | |
{ | |
if(String.IsNullOrWhiteSpace(key)) throw new ArgumentException("Invalid cache key"); | |
if(cachePopulate == null) throw new ArgumentNullException("cachePopulate"); | |
if(slidingExpiration == null && absoluteExpiration == null) throw new ArgumentException("Either a sliding expiration or absolute must be provided"); |