/// <summary> /// Builds this instance. /// </summary> /// <returns></returns> public ICacheItemProperties Build() { var sliding = TimeSpan.FromMinutes(this.slidingExpiration); // if there is a sliding expiration then absolute expiration must be set to DateTime.MaxValue var absolute = sliding > TimeSpan.Zero ? DateTime.MaxValue : DateTime.Now + TimeSpan.FromMinutes(this.absoluteExpiration); CacheItemProperties cip = new CacheItemProperties { SlidingExpiration = sliding, AbsoluteExpiration = absolute, CachePriority = CacheItemPriority.Normal }; return cip; }
/// <summary> /// Builds the specified sliding expiration. /// </summary> /// <param name="slidingExpiration">The sliding expiration.</param> /// <param name="absoluteExpiration">The absolute expiration.</param> /// <param name="cacheItemPriority">The cache item priority.</param> /// <param name="dependency">The dependency.</param> /// <param name="callback">The callback.</param> /// <returns></returns> public ICacheItemProperties Build(int slidingExpiration, int absoluteExpiration, CacheItemPriority cacheItemPriority, CacheDependency dependency, Delegate callback) { if (slidingExpiration < 0) { slidingExpiration = 0; } if (absoluteExpiration < 0) { absoluteExpiration = 0; } CacheItemProperties cip = new CacheItemProperties { SlidingExpiration = TimeSpan.FromMinutes(slidingExpiration), AbsoluteExpiration = absoluteExpiration > 0 ? DateTime.Now + TimeSpan.FromMinutes(absoluteExpiration) : DateTime.MaxValue, CachePriority = CacheItemPriority.Normal }; return cip; }