Cache.Insert("lstDownload", GetListDownload(), null,
DateTime.Now.AddDays(1), TimeSpan.Zero);
When will cache be exprired? What will we receive when cache expired?
Cache.Insert("lstDownload", GetListDownload(), null,
DateTime.Now.AddDays(1), TimeSpan.Zero);
When will cache be exprired? What will we receive when cache expired?
The item will be removed from the cache in at most 24 hours from now. It might be removed earlier if the worker process needs the memory for something else, or if the server or process is restarted. After that, asking the cache for an element with key lstDownload
will return null.
To improve readability of your code, consider using Cache.NoSlidingExpiration
instead of TimeSpan.Zero
. Both will do the very same thing, but the dedicated property provides more information about your intentions.
For an introduction to the subject, see Caching Application Data on MSDN.
It will expired after 24 hours from now. But if you do iisreset or KILL Worker process thread then it will going to expire.