Redigera

Dela via


Cache.NoSlidingExpiration Field

Definition

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 

Field Value

Examples

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)

Remarks

When used, this field sets the slidingExpiration parameter to the TimeSpan.Zero field, which has a constant value of zero. The cached item expires in accordance with the absoluteExpiration parameter associated with the Insert or Add method call.

Applies to

See also