use of com.graphhopper.gtfs.RealtimeFeed in project graphhopper by graphhopper.
the class RealtimeFeedLoadingCache method start.
@Override
public void start() {
this.transfers = new HashMap<>();
for (Map.Entry<String, GTFSFeed> entry : this.gtfsStorage.getGtfsFeeds().entrySet()) {
this.transfers.put(entry.getKey(), new Transfers(entry.getValue()));
}
this.executor = Executors.newSingleThreadExecutor();
this.cache = CacheBuilder.newBuilder().maximumSize(1).refreshAfterWrite(1, TimeUnit.MINUTES).build(new CacheLoader<String, RealtimeFeed>() {
public RealtimeFeed load(String key) {
return fetchFeedsAndCreateGraph();
}
@Override
public ListenableFuture<RealtimeFeed> reload(String key, RealtimeFeed oldValue) {
ListenableFutureTask<RealtimeFeed> task = ListenableFutureTask.create(() -> fetchFeedsAndCreateGraph());
executor.execute(task);
return task;
}
});
}
Aggregations