public void HandleEvent(Object eventObject, DateTime dispatchTime, long sequenceId) { if (!(eventObject is ClearAllCachesEvent)) { return; } CommittedRootCache.Clear(); IRootCache privilegedSecondLevelCache = SecondLevelCacheManager.SelectPrivilegedSecondLevelCache(false); if (privilegedSecondLevelCache != null && !Object.ReferenceEquals(privilegedSecondLevelCache, CommittedRootCache)) { privilegedSecondLevelCache.Clear(); } IRootCache nonPrivilegedSecondLevelCache = SecondLevelCacheManager.SelectNonPrivilegedSecondLevelCache(false); if (nonPrivilegedSecondLevelCache != null && !Object.ReferenceEquals(nonPrivilegedSecondLevelCache, CommittedRootCache) && !Object.ReferenceEquals(nonPrivilegedSecondLevelCache, privilegedSecondLevelCache)) { nonPrivilegedSecondLevelCache.Clear(); } IList <IWritableCache> firstLevelCaches = FirstLevelCacheManager.SelectFirstLevelCaches(); for (int a = firstLevelCaches.Count; a-- > 0;) { IWritableCache firstLevelCache = firstLevelCaches[a]; firstLevelCache.Clear(); } }
protected override void InterceptIntern(IInvocation invocation) { if (clearMethod.Equals(invocation.Method)) { IRootCache rootCache = privilegedRootCacheTL.Value; if (rootCache != null) { rootCache.Clear(); } rootCache = rootCacheTL.Value; if (rootCache != null) { rootCache.Clear(); } return; } ICacheIntern requestingCache = null; foreach (Object arg in invocation.Arguments) { if (arg is ICacheIntern) { requestingCache = (ICacheIntern)arg; break; } } bool privileged; if (requestingCache != null) { privileged = requestingCache.Privileged; } else { privileged = IsCurrentPrivileged(); } IRootCache rootCache2 = GetCurrentRootCache(privileged); invocation.ReturnValue = invocation.Method.Invoke(rootCache2, invocation.Arguments); }
public void DisposeTransactionalRootCache(bool success) { transactionalRootCacheActiveTL.Value = false; DisposeCurrentRootCache(rootCacheTL); IRootCache rootCache = privilegedRootCacheTL.Value; if (rootCache == null) { DisposeCurrentRootCache(privilegedRootCacheTL); // This may happen if an exception occurs while committing and therefore calling a rollback return; } try { if (success) { List <RootCacheValue> content = new List <RootCacheValue>(); // Save information into second level cache for committed data rootCache.GetContent(delegate(Type entityType, sbyte idIndex, Object id, Object value) { content.Add((RootCacheValue)value); } ); if (content.Count > 0) { rootCache.Clear(); CommittedRootCache.Put(content); } } } finally { DisposeCurrentRootCache(privilegedRootCacheTL); } }