コード例 #1
0
        /// <summary>
        /// Add object to cache container by specified expire sliding duration and priority type.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="slidingDuration"></param>
        /// <param name="cachePriorityType"></param>
        public void Add(object key, object value, TimeSpan slidingDuration, CachePriorityTypes cachePriorityType)
        {
            Kit.NotNull(key, "key");

            object cachedObject = HttpRuntime.Cache.Get(key.ToString());
            if (cachedObject != null)
                HttpRuntime.Cache.Remove(key.ToString());

            HttpRuntime.Cache.Add(key.ToString(), value, null, Cache.NoAbsoluteExpiration, slidingDuration, (CacheItemPriority)Enum.Parse(typeof(CacheItemPriority), cachePriorityType.ToString()), null);
        }
コード例 #2
0
        /// <summary>
        /// Add object to cache container by specified expire sliding duration and priority type.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="slidingDuration"></param>
        /// <param name="cachePriorityType"></param>
        public void Add(object key, object value, TimeSpan slidingDuration, CachePriorityTypes cachePriorityType)
        {
            Kit.NotNull(key, "key");

            if (!TransactionScopeContext.HasTransaction)
            {
                this.physicalCache.Add(key, value, slidingDuration, cachePriorityType);
                return;
            }

            this.CacheCommands[key] = new CacheCommand
            {
                Type = CacheCommandType.Add,
                Item = new CacheItem
                {
                    Key = key,
                    Value = value,
                    SlidingDuration = slidingDuration,
                    CachePriorityType = cachePriorityType
                }
            };
        }