缓存依赖性dependencies

CacheDependency fileDependency = new  CacheDependency(Server.Mappath( " NorthWind.xml " ));
Cache.Insert(
" GridViewDataSet " ,dsGrid,fileDependency);


string [] fileDependsArray  =   {Server.MapPath("Northwind.xml")} ;
             
string [] cacheDependsArray  =   {"Depend0""Depend1""Depend2"} ;
             CacheDependency cacheDepends 
=   new  CacheDependency
                                   (fileDependsArray, cacheDependsArray);
             Cache.Insert(
" GridViewDataSet " , dsGrid, cacheDepends,
                            DateTime.Now.AddSeconds(
10 ),
                                Cache.NoSlidingExpiration,
                                CacheItemPriority.Default,
                                onRemove);
Cache.Insert(参数)
参数
key

用于引用该对象的缓存键。

value

要插入缓存中的对象。

dependencies

该项的文件依赖项或缓存键依赖项。当任何依赖项更改时,该对象即无效,并从缓存中移除。如果没有依赖项,则此参数包含 空引用(在 Visual Basic 中为 Nothing)。

absoluteExpiration

所插入对象将过期并被从缓存中移除的时间。如果使用绝对过期,则 slidingExpiration 参数必须为 NoSlidingExpiration。

slidingExpiration

最后一次访问所插入对象时与该对象过期时之间的时间间隔。如果该值等效于 20 分钟,则对象在最后一次被访问 20 分钟之后将过期并被从缓存中移除。如果使用可调过期,则 absoluteExpiration 参数必须为 NoAbsoluteExpiration。

priority

该对象相对于缓存中存储的其他项的成本,由 CacheItemPriority 枚举表示。该值由缓存在退出对象时使用;具有较低成本的对象在具有较高成本的对象之前被从缓存移除。

onRemoveCallback

在从缓存中移除对象时将调用的委托(如果提供)。当从缓存中删除应用程序的对象时,可使用它来通知应用程序。

转载于:https://www.cnblogs.com/zwl12549/archive/2007/08/29/875143.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值