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(参数)
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);
参数
-
key
-
用于引用该对象的缓存键。
-
value
-
要插入缓存中的对象。
-
dependencies
-
该项的文件依赖项或缓存键依赖项。当任何依赖项更改时,该对象即无效,并从缓存中移除。如果没有依赖项,则此参数包含 空引用(在 Visual Basic 中为 Nothing)。
-
absoluteExpiration
-
所插入对象将过期并被从缓存中移除的时间。如果使用绝对过期,则 slidingExpiration 参数必须为 NoSlidingExpiration。
-
slidingExpiration
-
最后一次访问所插入对象时与该对象过期时之间的时间间隔。如果该值等效于 20 分钟,则对象在最后一次被访问 20 分钟之后将过期并被从缓存中移除。如果使用可调过期,则 absoluteExpiration 参数必须为 NoAbsoluteExpiration。
-
priority
-
该对象相对于缓存中存储的其他项的成本,由 CacheItemPriority 枚举表示。该值由缓存在退出对象时使用;具有较低成本的对象在具有较高成本的对象之前被从缓存移除。
-
onRemoveCallback
-
在从缓存中移除对象时将调用的委托(如果提供)。当从缓存中删除应用程序的对象时,可使用它来通知应用程序。