Notify consumer.

@param newCache the new cache
162899
void notifyConsumer(Map<String, ProviderGroup> newCache) {
        Map<String, ProviderGroup> oldCache = memoryCache;
        // 比较两个map的差异
        MapDifference<String, ProviderGroup> difference =
                new MapDifference<String, ProviderGroup>(newCache, oldCache);
        // 新的有，旧的没有，通知
        Map<String, ProviderGroup> onlynew = difference.entriesOnlyOnLeft();
        for (Map.Entry<String, ProviderGroup> entry : onlynew.entrySet()) {
            notifyConsumerListeners(entry.getKey(), entry.getValue());
        }
        // 旧的有，新的没有，全部干掉
        Map<String, ProviderGroup> onlyold = difference.entriesOnlyOnRight();
        for (Map.Entry<String, ProviderGroup> entry : onlyold.entrySet()) {
            notifyConsumerListeners(entry.getKey(), new ProviderGroup());
        }

        // 新旧都有，而且有变化
        Map<String, ValueDifference<ProviderGroup>> changed = difference.entriesDiffering();
        for (Map.Entry<String, ValueDifference<ProviderGroup>> entry : changed.entrySet()) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("{} has differente", entry.getKey());
            }
            ValueDifference<ProviderGroup> differentValue = entry.getValue();
            ProviderGroup innew = differentValue.leftValue();
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("new(right) is {}", innew);
            }
            // 只通知变化部分内容
            notifyConsumerListeners(entry.getKey(), innew);
        }
    }
651208
public void
setCache(Cache cache) {
	if (cache == null) {
		this.cache = new Cache(dclass);
		this.temporary_cache = true;
	} else {
		this.cache = cache;
		this.temporary_cache = false;
	}
}
557927
protected void sendEntryAddedEvent(CacheEntryEvent<T> event)
    {
        for (org.xwiki.cache.event.CacheEntryListener<T> listener : this.cacheEntryListeners
            .getListeners(org.xwiki.cache.event.CacheEntryListener.class)) {
            listener.cacheEntryAdded(event);
        }
    }
108208
public void code(Cache<G> cache, G xgen) throws APIException, IOException {
		code(null, null,cache,xgen);
	}
627061
public final void useCache(final boolean useCache) {
        synchronized (cache) {
            this.useCache = useCache;
            logger.logDebug(getClass(), useCache ? "Enabled" : "Disabled" + " caching");

            if (!useCache) {
                clearCache();
            }
        }
    }
285785
@Override
	public void cacheResult(
		List<CommerceNotificationQueueEntry> commerceNotificationQueueEntries) {
		for (CommerceNotificationQueueEntry commerceNotificationQueueEntry : commerceNotificationQueueEntries) {
			if (entityCache.getResult(
						CommerceNotificationQueueEntryModelImpl.ENTITY_CACHE_ENABLED,
						CommerceNotificationQueueEntryImpl.class,
						commerceNotificationQueueEntry.getPrimaryKey()) == null) {
				cacheResult(commerceNotificationQueueEntry);
			}
			else {
				commerceNotificationQueueEntry.resetOriginalValues();
			}
		}
	}
1093916
public void notifyObserversOfRequestFailure(CachedSpiceRequest<?> request) {
        RequestProcessingContext requestProcessingContext = new RequestProcessingContext();
        requestProcessingContext.setExecutionThread(Thread.currentThread());
        post(new RequestFailedNotifier(request, spiceServiceListenerList, requestProcessingContext));
    }
482177
@Override
	public void clearCache() {
		entityCache.clearCache(CommerceNotificationAttachmentImpl.class);

		finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
		finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
		finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
	}
988526
private void deliverCacheUpdate(SlotReference slot, MetadataCache cache) {
        for (final MetadataCacheListener listener : getCacheListeners()) {
            try {
                if (cache == null) {
                    listener.cacheDetached(slot);
                } else {
                    listener.cacheAttached(slot, cache);
                }
            } catch (Throwable t) {
                logger.warn("Problem delivering metadata cache update to listener", t);
            }
        }
    }
54755
public void setCachedConsumer(CATMainConsumer consumer)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "setCachedConsumer", consumer);
        this.cachedConsumer = consumer;
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "setCachedConsumer");
    }
1009820
public void broadcastStaleCacheData (String cache, Streamable data)
    {
        _nodeobj.setCacheData(new NodeObject.CacheData(cache, data));
    }
597332
@Override
	public void clearCache(
		CommerceNotificationQueueEntry commerceNotificationQueueEntry) {
		entityCache.removeResult(CommerceNotificationQueueEntryModelImpl.ENTITY_CACHE_ENABLED,
			CommerceNotificationQueueEntryImpl.class,
			commerceNotificationQueueEntry.getPrimaryKey());

		finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
		finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
	}
425993
protected void initCaches(int cacheSize) {

        m_offlineJsps = CmsMemoryMonitor.createLRUCacheMap(cacheSize);
        m_onlineJsps = CmsMemoryMonitor.createLRUCacheMap(cacheSize);
    }
792940
void overrideCacheFile(File newCacheFile)
  {
    this.cacheFile = newCacheFile;
    this.cacheDir = newCacheFile.getParentFile();
    this.baseCacheFileName = newCacheFile.getName();
  }
493978
@Override
	public void cacheResult(
		CommerceNotificationTemplateUserSegmentRel commerceNotificationTemplateUserSegmentRel) {
		entityCache.putResult(CommerceNotificationTemplateUserSegmentRelModelImpl.ENTITY_CACHE_ENABLED,
			CommerceNotificationTemplateUserSegmentRelImpl.class,
			commerceNotificationTemplateUserSegmentRel.getPrimaryKey(),
			commerceNotificationTemplateUserSegmentRel);

		finderCache.putResult(FINDER_PATH_FETCH_BY_C_C,
			new Object[] {
				commerceNotificationTemplateUserSegmentRel.getCommerceNotificationTemplateId(),
				commerceNotificationTemplateUserSegmentRel.getCommerceUserSegmentEntryId()
			}, commerceNotificationTemplateUserSegmentRel);

		commerceNotificationTemplateUserSegmentRel.resetOriginalValues();
	}
93205
protected static synchronized void initCache() {
        if (m_Cache == null) {
            m_Cache = new ClassCache();
            // failed to locate any classes on the classpath, maybe inside Weka?
            // try loading fixed list of classes
            if (m_Cache.isEmpty()) {
                InputStream inputStream = null;
                try {
                    inputStream = m_Cache.getClass().getResourceAsStream(CLASS_LIST);
                    m_Cache = new ClassCache(new FixedClassListTraversal(inputStream));
                }
                catch (Exception e) {
                    System.err.println("Failed to initialize class cache from fixed list (" + CLASS_LIST + ")!");
                    e.printStackTrace();
                }
                finally {
                    if (inputStream != null) {
                        try {
                            inputStream.close();
                        }
                        catch (Exception e) {
                            // ignored
                        }
                    }
                }
            }
        }
    }
950196
public void notifyShutdown() {
		// System.out.println(" AtomCache got notify shutdown..");
		if (pdpprovider != null) {
			if (pdpprovider instanceof RemotePDPProvider) {
				RemotePDPProvider remotePDP = (RemotePDPProvider) pdpprovider;
				remotePDP.flushCache();
			}
		}

		// todo: use a SCOP implementation that is backed by SerializableCache
		ScopDatabase scopInstallation = ScopFactory.getSCOP();
		if (scopInstallation != null) {
			if (scopInstallation instanceof CachedRemoteScopInstallation) {
				CachedRemoteScopInstallation cacheScop = (CachedRemoteScopInstallation) scopInstallation;
				cacheScop.flushCache();
			}
		}

	}