public void put(Object[] lookupKeys, EventTable rows) { Object key = DataCacheUtil.getLookupKey(lookupKeys); long now = schedulingService.getTime(); Item item = new Item(rows, now); cache.put(key, item); if (!isScheduled) { EPStatementHandleCallback callback = new EPStatementHandleCallback(epStatementAgentInstanceHandle, this); schedulingService.add(purgeIntervalMSec, callback, scheduleSlot); isScheduled = true; } }
public void scheduledTrigger(ExtensionServicesContext extensionServicesContext) { // purge expired long now = schedulingService.getTime(); Iterator<Object> it = cache.keySet().iterator(); for (; it.hasNext(); ) { Item item = cache.get(it.next()); if ((now - item.getTime()) > maxAgeMSec) { it.remove(); } } isScheduled = false; }
public EventTable getCached(Object[] lookupKeys) { Object key = DataCacheUtil.getLookupKey(lookupKeys); Item item = cache.get(key); if (item == null) { return null; } long now = schedulingService.getTime(); if ((now - item.getTime()) > maxAgeMSec) { cache.remove(key); return null; } return item.getData(); }