cacheById.put(id, cacheItem);
cacheByStockDb.put(stockDatabase, cacheItem);
}
private IStockDatabase getOrCreate(StockDatabaseHeader hdr) throws SQLException {
IStockDatabase stockDatabase;
StockDbCacheInfo cacheItem = cacheById.get(hdr.id);
if (cacheItem != null) {
stockDatabase = cacheItem.stockDatabase;
} else {
stockDatabase = new StockDatabase(hdr.contract, hdr.dataType, hdr.barSize, hdr.includeAfterHours, hdr.timeZone);
IMutableOHLCTimeSeries ohlcTimeSeries = stockDatabase.getOHLCTimeSeries();
for (IOHLCPoint ohlc : ohlcPointDao.find(hdr.id)) {
ohlcTimeSeries.addLast(ohlc);
}
IMutableTickTimeSeries tickTimeSeries = stockDatabase.getTickTimeSeries();
for (ITickPoint tick : tickPointDao.find(hdr.id)) {
tickTimeSeries.addLast(tick);
}
addToCache(stockDatabase, hdr.id);
}