use of io.siddhi.core.util.cache.CacheExpirer in project siddhi by wso2.
the class AbstractQueryableRecordTable method connectAndLoadCache.
@Override
protected void connectAndLoadCache() throws ConnectionUnavailableException {
connect();
if (cacheEnabled) {
((CacheTable) cacheTable).deleteAll();
StateEvent stateEventForCaching = new StateEvent(1, 0);
StreamEvent preLoadedData;
queryStoreWithoutCheckingCache.set(Boolean.TRUE);
try {
preLoadedData = query(stateEventForCaching, compiledConditionForCaching, compiledSelectionForCaching, outputAttributesForCaching);
} finally {
queryStoreWithoutCheckingCache.set(Boolean.FALSE);
}
if (preLoadedData != null) {
((CacheTable) cacheTable).addStreamEventUptoMaxSize(preLoadedData);
}
if (cacheExpiryEnabled) {
siddhiAppContext.getScheduledExecutorService().scheduleAtFixedRate(new CacheExpirer(retentionPeriod, cacheTable, tableMap, this, siddhiAppContext).generateCacheExpirer(), 0, purgeInterval, TimeUnit.MILLISECONDS);
}
}
}
Aggregations