JdbcAccessor extends DbAccessor.Commander<BEAN> { @Override public DbAccessor<BEAN> memoize() { Duration duration = Duration.ofMillis(dbBean.getCacheTtl()); return DbAccessor.BulkAccessor.from(this, dbBean.getCacheDepth(), GuavaCaches.ttlCache(duration)); } JdbcAccessor(@NonNull Logger logger, @NonNull BEAN dbBean, @NonNull ConnectionSupplier supplier); @Override Exception testDbBean(); @Override DbAccessor<BEAN> memoize();  }
@Test public void testCache() throws Exception { JdbcBean b2c1 = mydbTwoDimsBean(); b2c1.setCacheDepth(1); DbAccessor a2c1 = new JdbcAccessor(NOP_LOGGER, b2c1, mydbConnectionSupplier()).memoize(); DbSeries a2c1_first = a2c1.getSeriesWithData("Industry", "Belgium"); DbSeries a2c1_second = a2c1.getSeriesWithData("Industry", "Belgium"); assertEquals(a2c1_first, a2c1_second); assertSame(a2c1_first, a2c1_second); JdbcBean b2c2 = mydbTwoDimsBean(); b2c2.setCacheDepth(2); DbAccessor a2c2 = new JdbcAccessor(NOP_LOGGER, b2c2, mydbConnectionSupplier()).memoize(); DbSeries a2c2_first = a2c2.getSeriesWithData("Industry", "Belgium"); DbSeries a2c2_second = a2c2.getSeriesWithData("Industry", "Belgium"); assertEquals(a2c2_first, a2c2_second); assertSame(a2c2_first, a2c2_second); assertEquals(a2c1_first, a2c2_first); assertNotSame(a2c1_first, a2c2_first); }