当前位置: 首页>>代码示例>>C#>>正文


C# CacheItemRemovedCallback类代码示例

本文整理汇总了C#中CacheItemRemovedCallback的典型用法代码示例。如果您正苦于以下问题:C# CacheItemRemovedCallback类的具体用法?C# CacheItemRemovedCallback怎么用?C# CacheItemRemovedCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CacheItemRemovedCallback类属于命名空间,在下文中一共展示了CacheItemRemovedCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Set

        /// <summary>
        /// 添加缓存 (绝对有效期)
        /// </summary>
        /// <param name="cacheKey">缓存键值</param>
        /// <param name="cacheValue">缓存内容</param>
        /// <param name="timeout">绝对有效期(单位: 秒)</param>
        public static void Set(string cacheKey, object cacheValue, int timeout)
        {

            if (string.IsNullOrEmpty(cacheKey))
            {
                return;
            }

            if (null == cacheValue)
            {
                Remove(cacheKey);
                return;
            }

            CacheItemRemovedCallback callBack = new CacheItemRemovedCallback(onRemove);

            if (timeout <= 0)
            {
                cache.Insert(cacheKey, cacheValue, null, DateTime.MaxValue, TimeSpan.Zero, CacheItemPriority.High, callBack);
            }
            else
            {
                cache.Insert(cacheKey, cacheValue, null, DateTime.Now.AddSeconds(timeout), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, callBack);
            }
        }
开发者ID:windygu,项目名称:Dos.Common,代码行数:31,代码来源:CacheHelper.cs

示例2: BindSignal

        private void BindSignal(string virtualPath, CacheItemRemovedCallback callback)
        {
            string key = _prefix + virtualPath;

            //PERF: Don't add in the cache if already present. Creating a "CacheDependency"
            //      object (below) is actually quite expensive.
            if (HostingEnvironment.Cache.Get(key) != null)
                return;

            var cacheDependency = HostingEnvironment.VirtualPathProvider.GetCacheDependency(
                virtualPath,
                new[] { virtualPath },
                _clock.UtcNow);

            Logger.Debug("Monitoring virtual path \"{0}\"", virtualPath);

            HostingEnvironment.Cache.Add(
                key,
                virtualPath,
                cacheDependency,
                Cache.NoAbsoluteExpiration,
                Cache.NoSlidingExpiration,
                CacheItemPriority.NotRemovable,
                callback);
        }
开发者ID:gokhandisikara,项目名称:Coevery-Framework,代码行数:25,代码来源:DefaultVirtualPathMonitor.cs

示例3: CacheBuildResult

 internal override void CacheBuildResult(string cacheKey, BuildResult result, long hashCode, DateTime utcStart)
 {
     if (!BuildResultCompiledType.UsesDelayLoadType(result))
     {
         ICollection virtualPathDependencies = result.VirtualPathDependencies;
         CacheDependency dependencies = null;
         if (virtualPathDependencies != null)
         {
             dependencies = result.VirtualPath.GetCacheDependency(virtualPathDependencies, utcStart);
             if (dependencies != null)
             {
                 result.UsesCacheDependency = true;
             }
         }
         if (result.CacheToMemory)
         {
             CacheItemPriority normal;
             BuildResultCompiledAssemblyBase base2 = result as BuildResultCompiledAssemblyBase;
             if (((base2 != null) && (base2.ResultAssembly != null)) && !base2.UsesExistingAssembly)
             {
                 string assemblyCacheKey = BuildResultCache.GetAssemblyCacheKey(base2.ResultAssembly);
                 Assembly assembly = (Assembly) this._cache.Get(assemblyCacheKey);
                 if (assembly == null)
                 {
                     this._cache.UtcInsert(assemblyCacheKey, base2.ResultAssembly, null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
                 }
                 CacheDependency dependency2 = new CacheDependency(0, null, new string[] { assemblyCacheKey });
                 if (dependencies != null)
                 {
                     AggregateCacheDependency dependency3 = new AggregateCacheDependency();
                     dependency3.Add(new CacheDependency[] { dependencies, dependency2 });
                     dependencies = dependency3;
                 }
                 else
                 {
                     dependencies = dependency2;
                 }
             }
             string memoryCacheKey = GetMemoryCacheKey(cacheKey);
             if (result.IsUnloadable)
             {
                 normal = CacheItemPriority.Normal;
             }
             else
             {
                 normal = CacheItemPriority.NotRemovable;
             }
             CacheItemRemovedCallback onRemoveCallback = null;
             if (result.ShutdownAppDomainOnChange || (result is BuildResultCompiledAssemblyBase))
             {
                 if (this._onRemoveCallback == null)
                 {
                     this._onRemoveCallback = new CacheItemRemovedCallback(this.OnCacheItemRemoved);
                 }
                 onRemoveCallback = this._onRemoveCallback;
             }
             this._cache.UtcInsert(memoryCacheKey, result, dependencies, result.MemoryCacheExpiration, result.MemoryCacheSlidingExpiration, normal, onRemoveCallback);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:60,代码来源:MemoryBuildResultCache.cs

示例4: AddCache

 /// <summary>
 /// 建立缓存,并在移除时执行事件
 /// </summary>
 public static object AddCache(string key, object value, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemovedCallback)
 {
     if (HttpRuntime.Cache[key] == null && value != null)
         return HttpRuntime.Cache.Add(key, value, null, absoluteExpiration, slidingExpiration, priority, onRemovedCallback);
     else
         return null;
 }
开发者ID:pyfxl,项目名称:fxlweb,代码行数:10,代码来源:CacheHelper.cs

示例5: Set

 /// <summary>
 /// 本地缓存写入,包括分钟,是否绝对过期及缓存过期的回调
 /// </summary>
 /// <param name="name">key</param>
 /// <param name="value">value</param>
 /// <param name="minutes"缓存分钟></param>
 /// <param name="isAbsoluteExpiration">是否绝对过期</param>
 /// <param name="onRemoveCallback">缓存过期回调</param>
 public static void Set(string name, object value, int minutes, bool isAbsoluteExpiration, CacheItemRemovedCallback onRemoveCallback)
 {
     if (isAbsoluteExpiration)
         HttpRuntime.Cache.Insert(name, value, null, DateTime.Now.AddMinutes(minutes), Cache.NoSlidingExpiration, CacheItemPriority.Normal, onRemoveCallback);
     else
         HttpRuntime.Cache.Insert(name, value, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(minutes), CacheItemPriority.Normal, onRemoveCallback);
 }
开发者ID:NigelYu,项目名称:NewsSite,代码行数:15,代码来源:Caching.cs

示例6: Insert

 public void Insert(string key, object value, CacheDependency dependencies,
     DateTime absoluteExpiration, TimeSpan slidingExpiration,
     CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback)
 {
     _cache.Insert(key, value, dependencies, absoluteExpiration, slidingExpiration,
         priority, onRemoveCallback);
 }
开发者ID:jammycakes,项目名称:dolstagis.ideas,代码行数:7,代码来源:HttpRuntimeCache.cs

示例7: AddTask

		private void AddTask(string name, int seconds)
		{
			_onCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved);
			HttpRuntime.Cache.Insert(name, seconds, null,
				DateTime.Now.AddSeconds(seconds), System.Web.Caching.Cache.NoSlidingExpiration,
				CacheItemPriority.NotRemovable, _onCacheRemove);
		}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:7,代码来源:LegacyScheduledTasks.cs

示例8: CacheEntry

		internal CacheEntry (Cache objManager, string strKey, object objItem,CacheDependency objDependency,
				CacheItemRemovedCallback eventRemove, DateTime dtExpires, TimeSpan tsSpan,
				long longMinHits, bool boolPublic, CacheItemPriority enumPriority )
		{
			if (boolPublic)
				_enumFlags |= Flags.Public;

			_strKey = strKey;
			_objItem = objItem;
			_objCache = objManager;
			_onRemoved += eventRemove;
			_enumPriority = enumPriority;
			_ticksExpires = dtExpires.ToUniversalTime ().Ticks;
			_ticksSlidingExpiration = tsSpan.Ticks;

			// If we have a sliding expiration it overrides the absolute expiration (MS behavior)
			// This is because sliding expiration causes the absolute expiration to be 
			// moved after each period, and the absolute expiration is the value used 
			// for all expiration calculations.
			if (tsSpan.Ticks != Cache.NoSlidingExpiration.Ticks)
				_ticksExpires = DateTime.UtcNow.AddTicks (_ticksSlidingExpiration).Ticks;
			
			_objDependency = objDependency;
			if (_objDependency != null)
				// Add the entry to the cache dependency handler (we support multiple entries per handler)
				_objDependency.Changed += new CacheDependencyChangedHandler (OnChanged); 

			_longMinHits = longMinHits;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:29,代码来源:CacheEntry.cs

示例9: Insert

        public override void Insert(string cacheKey, object itemToCache, DNNCacheDependency dependency, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority,
                                   CacheItemRemovedCallback onRemoveCallback)
        {
            //onRemoveCallback += ItemRemovedCallback;

            //Call base class method to add obect to cache
            base.Insert(cacheKey, itemToCache, dependency, absoluteExpiration, slidingExpiration, priority, onRemoveCallback);
        }
开发者ID:robsiera,项目名称:OpenUrlRewriter,代码行数:8,代码来源:OpenUrlRewriterFBCachingProvider.cs

示例10: CachedLifetime

        public static IExpressionRegistration CachedLifetime(this IExpressionRegistration registration, TimeSpan slidingExpiration, CacheDependency dependency = null, CacheItemPriority itemPriority = CacheItemPriority.Default, CacheItemRemovedCallback itemRemovedCallback = null)
        {
            if (registration == null)
                throw new ArgumentNullException("registration");

            registration.SetLifetime(new CachedLifetime(slidingExpiration, dependency, itemPriority, itemRemovedCallback));
            return registration;
        }
开发者ID:GeorgeR,项目名称:DynamoIOC,代码行数:8,代码来源:LifetimeExtensions.cs

示例11: Add

 public static void Add(string key, object o, int time, TimeSpan timespan, CacheItemPriority priority, CacheItemRemovedCallback callback)
 {
     if (o == null)
     {
         return;
     }
     _cache.Insert(key, o, null, DateTime.Now.AddSeconds(time), timespan, priority, callback);
 }
开发者ID:shaohaiou,项目名称:comopp,代码行数:8,代码来源:MangaCache.cs

示例12: Initialize

        public override void Initialize(string name, NameValueCollection config)
        {
            if (String.IsNullOrEmpty(name))
                name = "InProc Session State Provider";
            base.Initialize(name, config);

            _callback = new CacheItemRemovedCallback(this.OnCacheItemRemoved);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:8,代码来源:InProcStateClientManager.cs

示例13: RemoveFileWithDelayInternal

 static void RemoveFileWithDelayInternal(string fileKey, object fileData, int delay, CacheItemRemovedCallback removeAction) {
     string key = RemoveTaskKeyPrefix + fileKey;
     if(HttpRuntime.Cache[key] == null) {
         DateTime absoluteExpiration = DateTime.UtcNow.Add(new TimeSpan(0, delay, 0));
         HttpRuntime.Cache.Insert(key, fileData, null, absoluteExpiration,
             Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, removeAction);
     }
 }
开发者ID:osmania,项目名称:MvcCharts,代码行数:8,代码来源:UploadingUtils.cs

示例14: AddObject

        /// <summary>
        /// 加入当前对象到缓存中
        /// </summary>
        /// <param name="objId">key for the object</param>
        /// <param name="o">object</param>
        public void AddObject(string objId, object o)
        {
            if (objId == null || objId.Length == 0 || o == null)
                return;

            CacheItemRemovedCallback callBack = new CacheItemRemovedCallback(onRemove);
            webCacheforfocus.Insert(objId, o, null, DateTime.Now.AddMinutes(TimeOut), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.High, callBack);
        }
开发者ID:yeyong,项目名称:manageserver,代码行数:13,代码来源:TaoBaoCacheStrategy.cs

示例15: Insert

		public void Insert(string Key, object Obj, CacheDependency Dependency, double TimeOut, TimeSpan SlidingExpiration, CacheItemPriority Priority, CacheItemRemovedCallback RemovedCallback)
		{
			if ((Obj != null)) {
				Cache Cache = HttpRuntime.Cache;
				if (Cache [Key] == null) {
					Cache.Insert(Key, RuntimeHelpers.GetObjectValue(Obj), Dependency, DateTime.Now.AddSeconds(TimeOut), SlidingExpiration, Priority, RemovedCallback);
				}
			}
		}
开发者ID:Aaronguo,项目名称:Fx.InformationPlatform.,代码行数:9,代码来源:CacheManager.cs


注:本文中的CacheItemRemovedCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。