Esempio n. 1
0
        private static void HandleExpiration <T>(HttpCacheShim that
                                                 , CacheAddParameters <T> parameters
                                                 , string cacheKey
                                                 , CacheItemUpdateReason reason
                                                 , out object expensiveObject
                                                 , out CacheDependency dependency
                                                 , out DateTime absoluteExpiration
                                                 , out TimeSpan slidingExpiration)
            where T : class
        {
            Log("Expired", () => "(" + reason + ") " + cacheKey);

            expensiveObject    = null;
            dependency         = null;
            absoluteExpiration = Cache.NoAbsoluteExpiration;
            slidingExpiration  = Cache.NoSlidingExpiration;

            // if we were not shutting down, might want to handle the reuse/refresh
            if (reason == CacheItemUpdateReason.Expired &&
                !AppDomain.CurrentDomain.IsFinalizingForUnload())
            {
                if (parameters.ShouldScheduleRefresh &&
                    HttpCacheShim.DisableBackfill == false &&
                    !BackgroundQueue.IsBacklogged())
                {
                    // we need queue a request to the underlying store to get more current data into the cache so it stays primed.
                    BackgroundQueue.Enqueue(parameters);
                }
            }
        }