Search in sources :

Example 1 with CacheExpirer

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);
        }
    }
}
Also used : OnDemandQueryParser.generateMatchingMetaInfoHolderForCacheTable(io.siddhi.core.util.parser.OnDemandQueryParser.generateMatchingMetaInfoHolderForCacheTable) CacheTable(io.siddhi.core.table.CacheTable) OnDemandQueryRuntimeUtil.executeSelectorAndReturnStreamEvent(io.siddhi.core.util.OnDemandQueryRuntimeUtil.executeSelectorAndReturnStreamEvent) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) MetaStateEvent(io.siddhi.core.event.state.MetaStateEvent) StateEvent(io.siddhi.core.event.state.StateEvent) CacheExpirer(io.siddhi.core.util.cache.CacheExpirer)

Aggregations

MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)1 StateEvent (io.siddhi.core.event.state.StateEvent)1 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)1 StreamEvent (io.siddhi.core.event.stream.StreamEvent)1 CacheTable (io.siddhi.core.table.CacheTable)1 OnDemandQueryRuntimeUtil.executeSelectorAndReturnStreamEvent (io.siddhi.core.util.OnDemandQueryRuntimeUtil.executeSelectorAndReturnStreamEvent)1 CacheExpirer (io.siddhi.core.util.cache.CacheExpirer)1 OnDemandQueryParser.generateMatchingMetaInfoHolderForCacheTable (io.siddhi.core.util.parser.OnDemandQueryParser.generateMatchingMetaInfoHolderForCacheTable)1