本文整理汇总了Java中org.apache.ignite.IgniteCache.removeAll方法的典型用法代码示例。如果您正苦于以下问题:Java IgniteCache.removeAll方法的具体用法?Java IgniteCache.removeAll怎么用?Java IgniteCache.removeAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.IgniteCache
的用法示例。
在下文中一共展示了IgniteCache.removeAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cleanExpiredRecords
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Scheduled(initialDelayString = "${initialDelay}", fixedDelayString = "${fixedDelay}")
public void cleanExpiredRecords(){
// query the matching records first
logger.debug("Starting the clean up job to clear the expired records");
long towMinutesRange = System.currentTimeMillis()-900000;
final IgniteCache<String, List<AlertEntry>> alertsCache = getAlertsCache();
final String sql = "select * from AlertEntry where timestamp <= ?";
SqlQuery<String,AlertEntry> query = new SqlQuery(AlertEntry.class,sql);
query.setArgs(towMinutesRange);
final List<Cache.Entry<String, AlertEntry>> toDeleteAlerts = alertsCache.query(query).getAll();
// then call remove all as this will remove the records from the cache and the persistent file system as sql delete will just delete it from the cache layer not the file system
// or the persistent store
if(toDeleteAlerts!=null && !toDeleteAlerts.isEmpty()){
logger.debug("Finished cleaning out {} records",toDeleteAlerts.size());
alertsCache.removeAll(new HashSet(toDeleteAlerts
.stream()
.map(Cache.Entry::getKey)
.collect(Collectors.toList())));
}
}