Reputation: 1237
hy,
How can use absoluteExpiration
and slidingExpiration
, if i specify both of them i get
:absoluteExpiration must be DateTime.MaxValue or slidingExpiration must be timeSpan.Zero.
Cache.Insert("cachetest", value, Nothing, ??,??;
Thanks,
Upvotes: 3
Views: 7189
Reputation: 96576
For sliding expiration, use this:
Cache.Insert(key, value, Nothing,
Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(10))
For absolute expiration, use this:
Cache.Insert(key, value, Nothing,
DateTime.Now.AddMinutes(2), Cache.NoSlidingExpiration)
Upvotes: 4
Reputation: 2674
You must use one or the other. From the Microsoft documentation at http://msdn.microsoft.com/en-us/library/05kd8d77.aspx
absoluteExpiration
... If you are using absolute expiration, the slidingExpiration parameter must be NoSlidingExpiration.
slidingExpiration
...If you are using sliding expiration, the absoluteExpiration parameter must be NoAbsoluteExpiration.
Upvotes: 1