本文整理汇总了C#中CacheItemRemovedCallback类的典型用法代码示例。如果您正苦于以下问题:C# CacheItemRemovedCallback类的具体用法?C# CacheItemRemovedCallback怎么用?C# CacheItemRemovedCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CacheItemRemovedCallback类属于命名空间,在下文中一共展示了CacheItemRemovedCallback类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: AddTask
private void AddTask(string taskName, int seconds)
{
// http://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/
OnCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved);
HttpRuntime.Cache.Insert(taskName, seconds, null,
DateTime.Now.AddSeconds(seconds), Cache.NoSlidingExpiration,
CacheItemPriority.NotRemovable, OnCacheRemove);
}
开发者ID:pmn,项目名称:planetcsharp,代码行数:9,代码来源:Global.asax.cs
示例17: Insert
public void Insert(string key, object value, CacheItemRemovedCallback cacheItemRemovedCallback, params string[] fileDependencies)
{
if (key.HasValue() && value != null)
{
HttpRuntime.Cache.Insert(key, value, fileDependencies.Any() ? new CacheDependency(fileDependencies) : null,
System.Web.Caching.Cache.NoAbsoluteExpiration, System.Web.Caching.Cache.NoSlidingExpiration,
CacheItemPriority.Normal, cacheItemRemovedCallback);
}
}
开发者ID:jstevenson81,项目名称:wodgeaux,代码行数:9,代码来源:CacheProvider.cs
示例18: InsertCache
/// <summary>
/// 增加一个缓存对象
/// </summary>
/// <param name="strKey">键值名称</param>
/// <param name="valueObj">被缓存对象</param>
/// <param name="timeSpan">缓存失效时间,默认为3分钟</param>
/// <param name="priority">保留优先级(枚举数值),1最不会被清除,6最容易被内存管理清除,0为default
/// 【1:NotRemovable;2:High;3:AboveNormal;4:Normal;5:BelowNormal;6:Low】</param>
/// <returns>缓存写入是否成功true 、 false</returns>
public static bool InsertCache(string strKey, object valueObj, TimeSpan timeSpan, int priority)
{
TimeSpan ts;
if (strKey != null && strKey.Length != 0 && valueObj != null)
{
//建立回调委托的一个实例
//onRemove是委托执行的函数,具体方法看下面的onRemove(...)
CacheItemRemovedCallback callBack = new CacheItemRemovedCallback(onRemove);
#region 失效时间设置
if (timeSpan == null)
{
ts = new TimeSpan(0, 3, 0);//如果不进行设置则为三分钟
}
else
{
ts = timeSpan;
}
#endregion
#region System.Web.Caching.Cache 对象中存储的项的相对优先级
CacheItemPriority cachePriority;
switch (priority)
{
case 6:
cachePriority = CacheItemPriority.Low;
break;
case 5:
cachePriority = CacheItemPriority.BelowNormal;
break;
case 4:
cachePriority = CacheItemPriority.Normal;
break;
case 3:
cachePriority = CacheItemPriority.AboveNormal;
break;
case 2:
cachePriority = CacheItemPriority.High;
break;
case 1:
cachePriority = CacheItemPriority.NotRemovable;
break;
default:
cachePriority = CacheItemPriority.Default;
break;
}
#endregion
HttpRuntime.Cache.Insert(strKey, valueObj, null, DateTime.Now.Add(ts), System.Web.Caching.Cache.NoSlidingExpiration, cachePriority, callBack);
return true;
}
else
{
return false;
}
}
开发者ID:yangzhiping2012,项目名称:GTJA,代码行数:65,代码来源:AspNetChacheHelper.cs
示例19: CachedLifetime
public static IConfigurableRegistration CachedLifetime(this IConfigurableRegistration registration, CacheDependency dependency = null, CacheItemPriority itemPriority = CacheItemPriority.Default, CacheItemRemovedCallback itemRemovedCallback = null)
{
// HttpCachedLifetime / CachedLifetime ?
if (registration == null)
throw new ArgumentNullException("registration");
registration.SetLifetime(new CachedLifetime(dependency, itemPriority, itemRemovedCallback));
return registration;
}
开发者ID:thanhvc,项目名称:DynamoIOC,代码行数:10,代码来源:LifetimeExtensions.cs
示例20: InsertType
public static void InsertType (Type type, string filename, string key,
CacheItemRemovedCallback removed_callback)
{
//string [] cacheKeys = new string [] { cachePrefix + filename };
//CacheDependency dep = new CacheDependency (null, cacheKeys);
CacheDependency dep = new CacheDependency (filename);
HttpRuntime.Cache.Insert (cacheTypePrefix + key, type, dep,
Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,
CacheItemPriority.Normal, removed_callback);
}
开发者ID:nickchal,项目名称:pash,代码行数:11,代码来源:CachingCompiler.cs
注:本文中的CacheItemRemovedCallback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论