internal /*public*/ void DoDelete(HttpContext context) { string key = CreateKey(context.Request); CacheStoreProvider cacheInternal = HttpRuntime.Cache.InternalCache; CachedContent content = (CachedContent)cacheInternal.Get(key); /* If the item isn't there, we probably took too long to run. */ if (content == null) { ReportNotFound(context); return; } int lockCookie; if (!GetOptionalNonNegativeInt32HeaderValue(context, StateHeaders.LOCKCOOKIE_NAME, out lockCookie)) { return; } content._spinLock.AcquireWriterLock(); try { if (content._content == null) { ReportNotFound(context); return; } /* Only remove the item if we are the owner */ if (content._locked && (lockCookie == -1 || content._lockCookie != lockCookie)) { ReportLocked(context, content); return; } /* * If not locked, keep it locked until it is completely removed. * Prevent overwriting when we drop the lock. */ content._locked = true; content._lockCookie = 0; } finally { content._spinLock.ReleaseWriterLock(); } cacheInternal.Remove(key); }
// Remove an item. Note that the item is originally obtained by GetExclusive // Same note as Set on lockId public override void RemoveItem(HttpContext context, String id, object lockId, SessionStateStoreData item) { Debug.Assert(lockId != null, "lockId != null"); string key = CreateSessionStateCacheKey(id); CacheStoreProvider cacheInternal = HttpRuntime.Cache.InternalCache; int lockCookie = (int)lockId; SessionIDManager.CheckIdLength(id, true /* throwOnFail */); InProcSessionState state = (InProcSessionState)cacheInternal.Get(key); /* If the item isn't there, we probably took too long to run. */ if (state == null) { return; } state._spinLock.AcquireWriterLock(); try { /* Only remove the item if we are the owner */ if (!state._locked || state._lockCookie != lockCookie) { return; } /* prevent overwriting when we drop the lock */ state._lockCookie = 0; } finally { state._spinLock.ReleaseWriterLock(); } cacheInternal.Remove(key); TraceSessionStats(); }
// Remove CachedPathData when the first request for the path results in a // 400 range error. We need to remove all data up the path to account for // virtual files. // An example of a 400 range error is "path not found". static internal void RemoveBadPathData(CachedPathData pathData) { CacheStoreProvider cacheInternal = HttpRuntime.Cache.InternalCache; string configPath = pathData._configPath; string key = CreateKey(configPath); while (pathData != null && !pathData.CompletedFirstRequest && !pathData.Exists) { cacheInternal.Remove(key); configPath = ConfigPathUtility.GetParent(configPath); if (configPath == null) { break; } key = CreateKey(configPath); pathData = (CachedPathData)cacheInternal.Get(key); } }