Set Expire property of data cache

  • Thread starter Thread starter Deep
  • Start date Start date
D

Deep

Dear Friends
How to set Expire property of cache in Data Caching.

I have taken one Cache["myData"]

I only have to give its expire property, not any other property.
I just want Cache should expire after 15 minute.

Please help me. How to do it.


Thanks in Advance
 
Deep said:
How to set Expire property of cache in Data Caching.

I have taken one Cache["myData"]

I only have to give its expire property, not any other property.
I just want Cache should expire after 15 minute.

If you want to set expiration, you need to use the longer "Cache.Insert"
method instead of the indexer:

Cache.Insert("myData", value, null, absoluteExpiration, slidingExpiration);

You use only one of the two "expiration" parameters:
- Absolute if you want your cache to expire unconditionally at a
fixed time, such as DateTime.Now.AddMinutes(15).
- Sliding if you want the cache to expire after a period of
inactivity. For instance, specify TimeSpan.FromMinutes(15).
 
Back
Top