@ Override public int purgeCacheEntries ( CacheEntryTag tag ) { final String tagType = tag . getTagType ( ) ; final Set < Ehcache > caches = taggedCaches . getIfPresent ( tagType ) ; // Tag exists in cache(s) if ( caches == null || caches . isEmpty ( ) ) { return 0 ; } int purgeCount = 0 ; // Iterate over each cache to remove the tagged entries for ( final Ehcache cache : caches ) { final String cacheName = cache . getName ( ) ; // See if there are any tagged cache keys for the cache final LoadingCache < CacheEntryTag , Set < Object > > cacheKeys = taggedCacheKeys . getIfPresent ( cacheName ) ; if ( cacheKeys != null ) { // Remove all cache keys from the cache final Set < Object > taggedKeys = cacheKeys . asMap ( ) . remove ( tag ) ; if ( taggedKeys != null ) { final int keyCount = taggedKeys . size ( ) ; purgeCount += keyCount ; logger . debug ( "Removing {} keys from {} for tag {}" , keyCount , cacheName , tag ) ; cache . removeAll ( taggedKeys ) ; } } } return purgeCount ; }
Remove all cache entries with keys that have the specified tag