public List<Object> retrieveCache(AtmosphereResource r, BroadcasterTracker tracker, boolean force) {
List<Object> cachedMessages = new LinkedList<Object>();
for (String broadcasterID : tracker.ids()) {
Broadcaster b = factory.lookup(broadcasterID, false);
BroadcasterCache cache;
logger.trace("About to retrieve cached messages for resource {} with Broadcaster {}, tracked by " + b, r.uuid(), r.getBroadcaster());
if (b != null && (force || !b.getID().equalsIgnoreCase(r.getBroadcaster().getID()))) {
// We cannot add the resource now. we need to first make sure there is no cached message.
cache = b.getBroadcasterConfig().getBroadcasterCache();
List<Object> t = cache.retrieveFromCache(b.getID(), r.uuid());
cachedMessages = b.getBroadcasterConfig().applyFilters(r, t);
if (t.size() > 0) {
logger.trace("Found Cached Messages For AtmosphereResource {} with Broadcaster {}", r.uuid(), broadcasterID);
cachedMessages.addAll(t);