@Override protected boolean removeEldestEntry( Map.Entry<TimelineEntityGroupId, EntityCacheItem> eldest) { if (super.size() > appCacheMaxSize) { TimelineEntityGroupId groupId = eldest.getKey(); LOG.debug("Evicting {} due to space limitations", groupId); EntityCacheItem cacheItem = eldest.getValue(); cacheItem.releaseCache(groupId); if (cacheItem.getAppLogs().isDone()) { appIdLogMap.remove(groupId.getApplicationId()); } return true; } return false; } });