Refreshing cache

Topics: Caching Application Block
Jul 23, 2008 at 6:45 AM
Hi, I have a windows service which has multiple set of threads, each set of thread is doing activities like "file collection", "file validation" and "file dispatch". For doing these activities, there are certain configurations, which are stored in the cache. Each of the thread reads some of these configuration to complete the process. I have loaded the cache once when the service starts. I have set the expiration policy (using ExtendedFormatTime to expire every 24 hours) and the refresh action. In the refresh method currently, I am doing the following (which I am not satisfied with): 1] Internally Stop all the threads. 2] reload the cache. and 3] Start all the threads.

Now the problem is, the refresh event fires only after the item has been removed from the cache. If any of the thread tries to access the data from the cache, it fails.

Is there a way to identify that the time is up and the cache need to be refreshed now, before the cacheitem has actually been removed from the cache? Or may be I can identify the time is up and I just block all the running threads and refresh the expired cache item and proceed.

Thanks.