Example #1
0
        public void Add(string key, object value, DateTime dateTime, OnCacheRemoved onCacheRemoved)
        {
            if (!enableCache)
            {
                return;
            }
            CacheItemRemovedCallback onRemoveCallback = null;

            if (onCacheRemoved != null)
            {
                AspCachingOnRemove aspCachingOnRemove = new AspCachingOnRemove();
                onRemoveCallback = new CacheItemRemovedCallback(aspCachingOnRemove.RemovedCallback);
                aspCachingOnRemove.RemoveEvent += new AspCachingOnRemove.RemoveHandler(onCacheRemoved.RemoveHandler);
            }
            cache.Insert(key, value, null, dateTime, TimeSpan.Zero, CacheItemPriority.NotRemovable, onRemoveCallback);
        }
Example #2
0
        public void Add(string key, object value, string filepath, OnCacheRemoved onCacheRemoved)
        {
            if (!enableCache)
            {
                return;
            }
            CacheItemRemovedCallback onRemoveCallback = null;

            if (onCacheRemoved != null)
            {
                AspCachingOnRemove aspCachingOnRemove = new AspCachingOnRemove();
                onRemoveCallback = new CacheItemRemovedCallback(aspCachingOnRemove.RemovedCallback);
                aspCachingOnRemove.RemoveEvent += new AspCachingOnRemove.RemoveHandler(onCacheRemoved.RemoveHandler);
            }
            CacheDependency dep = new CacheDependency(filepath);

            cache.Insert(key, value, dep, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, onRemoveCallback);
        }
Example #3
0
 public void Add(string key, object value, int minutes, OnCacheRemoved onCacheRemoved)
 {
     Add(key, value, DateTime.Now.AddMinutes(minutes), onCacheRemoved);
 }