/** * Indicates whether or not the cache entry is stale. * * @param cacheEntry The cache entry to test the freshness of. * @param refreshPeriod The maximum allowable age of the entry, in seconds. * @param cronExpiry A cron expression specifying absolute date(s) and/or time(s) that the cache * entry should expire at. If the cache entry was refreshed prior to the most recent match for * the cron expression, the entry will be considered stale. * @return <code>true</code> if the entry is stale, <code>false</code> otherwise. */ protected boolean isStale(CacheEntry cacheEntry, int refreshPeriod, String cronExpiry) { boolean result = cacheEntry.needsRefresh(refreshPeriod) || isFlushed(cacheEntry); if ((!result) && (cronExpiry != null) && (cronExpiry.length() > 0)) { try { FastCronParser parser = new FastCronParser(cronExpiry); result = result || parser.hasMoreRecentMatch(cacheEntry.getLastUpdate()); } catch (ParseException e) { log.warn(e); } } return result; }
/** * Flushes all unexpired objects that belong to the supplied group. On completion this method * fires a <tt>CacheEntryEventType.GROUP_FLUSHED</tt> event. * * @param group The group to flush * @param origin The origin of this flush event (optional) */ public void flushGroup(String group, String origin) { // Flush all objects in the group Set groupEntries = cacheMap.getGroup(group); if (groupEntries != null) { Iterator itr = groupEntries.iterator(); String key; CacheEntry entry; while (itr.hasNext()) { key = (String) itr.next(); entry = (CacheEntry) cacheMap.get(key); if ((entry != null) && !entry.needsRefresh(CacheEntry.INDEFINITE_EXPIRY)) { flushEntry(entry, NESTED_EVENT); } } } if (listenerList.getListenerCount() > 0) { dispatchCacheGroupEvent(CacheEntryEventType.GROUP_FLUSHED, group, origin); } }