Last post Nov 03, 2016 05:19 AM by Nan Yu
Oct 28, 2016 08:55 PM|asanders2552|LINK
In our project, we load the data using webservices into cache to speed up the pages response time for the users. The webservices are running in the background every 5 min, however in the code we only have checks that the cache is not null and therefore it
doesn't refresh it timely. What is the best way to refresh cache to ensure that the latest data is pulled and refreshed at least
every hour. Thank you!
Oct 31, 2016 07:38 AM|Nan Yu|LINK
You could try to set cache with a fixed expiration , then re-add the items in callback when cache expires . See CacheItemRemovedCallback ,
you could also refer to below articles for more details and solutions :
Nov 02, 2016 12:13 PM|asanders2552|LINK
Thank you. When I set the cache - I do not use Add command.
HttpRuntime.Cache["TodayEvents"] = TodayEvents;
So not sure how can I set cache expiration for the command above? Thanks
Nov 03, 2016 05:19 AM|Nan Yu|LINK
Then use add method :
If you use like :
That will add object without an explicit expiration set , that means the object will not automatically be removed from the cache, unless the runtime decides to remove stuff from the cache due to high memory usage.