i use HttpRuntime.Cache.Insert to insert data into cache. i have the function 'onremove' as the cacheitemremovedcallback - when the cache expires (after 15 minutes) it releases data in cache and calls 'onremove' that insert the data again to the cache.
everytime i want to use the data in the cache i check that the data is there first:
if (HttpRuntime.Cache[CACHE_DATA_TABLE] == null)
{ // load data into cache again}
what happens if i check that the data is in the cache and it is there, but as soon as i want to use it it expires? so when i call:
DATADT = (DataTable)HttpRuntime.Cache[CACHE_DATA_TABLE]
Does the HttpRuntime.Cache waits untill 'onremove' is called and finish loading the data back into cache before it extract the data ?
You should use a CacheItemUpdateCallback delegate instead.
This lets you take the desired action before the item is about to be removed.
See: MSDN on Cache.Insert Method (String, Object, CacheDependency, DateTime, TimeSpan, CacheItemUpdateCallback)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With