RemoveFromProvider() static private method

static private RemoveFromProvider ( string key, string providerName ) : void
key string
providerName string
return void
Example #1
0
        // only used by providers
        private static void DependencyRemovedCallback(string key, object value, CacheItemRemovedReason reason)
        {
            Debug.Trace("OutputCache", "DependencyRemovedCallback: reason=" + reason + ", key=" + key);

            DependencyCacheEntry dce = value as DependencyCacheEntry;

            if (dce.KernelCacheEntryKey != null)
            {
                // invalidate kernel cache entry
                if (HttpRuntime.UseIntegratedPipeline)
                {
                    UnsafeIISMethods.MgdFlushKernelCache(dce.KernelCacheEntryKey);
                }
                else
                {
                    UnsafeNativeMethods.InvalidateKernelCache(dce.KernelCacheEntryKey);
                }
            }
            if (reason == CacheItemRemovedReason.DependencyChanged)
            {
                if (dce.OutputCacheEntryKey != null)
                {
                    try {
                        OutputCache.RemoveFromProvider(dce.OutputCacheEntryKey, dce.ProviderName);
                    }
                    catch (Exception e) {
                        HandleErrorWithoutContext(e);
                    }
                }
            }
        }
Example #2
0
        // lookup cached vary
        // lookup entry
        // lookup entry for content-encoding
        internal static Object Get(String key)
        {
            // if it's not in the provider or the default provider is undefined,
            // check the internal cache (we don't know where it is).
            Object result = null;
            OutputCacheProvider provider = GetProvider(HttpContext.Current);

            if (provider != null)
            {
                result = provider.Get(key);
                OutputCacheEntry oce = result as OutputCacheEntry;
                if (oce != null)
                {
                    if (HasDependencyChanged(false /*isFragment*/, oce.DependenciesKey, oce.Dependencies, oce.KernelCacheUrl, key, provider.Name))
                    {
                        OutputCache.RemoveFromProvider(key, provider.Name);
#if DBG
                        Debug.Trace("OutputCache", "Get(" + key + ") --> null, " + provider.Name);
#endif
                        return(null);
                    }
                    result = Convert(oce);
                }
            }
            if (result == null)
            {
                result = HttpRuntime.CacheInternal.Get(key);
#if DBG
                string typeName = (result != null) ? result.GetType().Name : "null";
                Debug.Trace("OutputCache", "Get(" + key + ") --> " + typeName + ", CacheInternal");
            }
            else
            {
                Debug.Trace("OutputCache", "Get(" + key + ") --> " + result.GetType().Name + ", " + provider.Name);
#endif
            }
            return(result);
        }