EL 2.0 Preload Cache...

Topics: Caching Application Block
May 19, 2007 at 12:36 AM
I am having some issues preloading the EL cache. Pseudo code is below. Does anyone see any issues with this logic? If you need more information, please let me know. For some reason the item being called from cache is trying to load multiple times and my logic should prevent that. Also, when the refresh key I have set clears, I am getting multiple calls to my load caching method. Not sure how or why this is happening under heavy load.

     // **** WARNING... PSEUDO CODE ***
     private void LoadBigHeavyItem()
                    // load for first time so everyone gets to wait
               } else {
                    // we need to wait and call it again since the cache should already be refreshing
                    // this is only to handle initial load
          } else if(!Cache.Contains("RefreshKey")) {
               // if refresh key is gone we need to reload the cache while still serving
               // reset cache key so this if block doesn't get called again
               Cache.Add("RefreshKey"); // expire in 5 minutes please
               // kick off thread to reload cache.
               ThreadStart ThrdStart = new ThreadStart(Blah.RefreshCache);
               Thread Thrd = new Thread(ThrdStart);
          // if we didn't hit the if blocks we are good to go.
     private void RefreshCache()
          Cache.Add("RefreshKey"); // expires in 5 minutes
          Cache.Add("BigHeavyCacheItem"); // expires in 10 minutes
May 21, 2007 at 10:33 PM
Anyone have any ideas on the above? Sorry for the bump, but I am getting a little lost as to why this doesn't work.