예제 #1
0
        /// <summary>
        /// Builds this instance.
        /// </summary>
        /// <returns></returns>
        public ICacheItemProperties Build()
        {
            CacheItemProperties cip = new CacheItemProperties
            {
                SlidingExpiration = TimeSpan.FromMinutes(this.slidingExpiration),
                AbsoluteExpiration = DateTime.Now + TimeSpan.FromMinutes(this.absoluteExpiration),
                CachePriority = CacheItemPriority.Normal
            };

            return cip;
        }
예제 #2
0
        /// <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;
        }