Cache.NoSlidingExpiration 字段


用作 Insert(String, Object)Add(String, Object, CacheDependency, DateTime, TimeSpan, CacheItemPriority, CacheItemRemovedCallback) 方法调用中的 slidingExpiration 参数,以禁用可调到期。Used as the slidingExpiration parameter in an Insert(String, Object) or Add(String, Object, CacheDependency, DateTime, TimeSpan, CacheItemPriority, CacheItemRemovedCallback) method call to disable sliding expirations. 此字段为只读。This field is read-only.

public: static initonly TimeSpan NoSlidingExpiration;
public static readonly TimeSpan NoSlidingExpiration;
 staticval mutable NoSlidingExpiration : TimeSpan
Public Shared ReadOnly NoSlidingExpiration As TimeSpan 



下面的示例演示如何使用 Insert 方法将项添加到Cache NoSlidingExpiration使用字段的对象。The following example demonstrates how to use the Insert method to add an item to the Cache object using the NoSlidingExpiration field.

Cache.Insert("DSN", connectionString, null, DateTime.Now.AddMinutes(2), System.Web.Caching.Cache.NoSlidingExpiration);
Cache.Insert("DSN", connectionString, Nothing, DateTime.Now.AddMinutes(2), System.Web.Caching.Cache.NoSlidingExpiration)


使用时, 此字段将slidingExpiration参数设置TimeSpan.Zero为字段, 该字段的常量值为零。When used, this field sets the slidingExpiration parameter to the TimeSpan.Zero field, which has a constant value of zero. 缓存项会根据absoluteExpiration Insert与或Add方法调用关联的参数过期。The cached item expires in accordance with the absoluteExpiration parameter associated with the Insert or Add method call.