@Test public void testPutL1() throws ExecutionException { cache.put(KEY, new String(TEST_VALUE_1)); String res = cache.get(KEY, () -> { counter.incrementAndGet(); return new String(TEST_VALUE_2); }); assertEquals(TEST_VALUE_1, res); assertEquals(0, counter.get()); }
@Test public void testPutL2() throws ExecutionException { FakeTicker ticker = new FakeTicker(); cache = new SmallTableCache.SmallTableLocalCache<>(ticker); cache.put(KEY, new String(TEST_VALUE_1)); String res = cache.get(KEY, () -> { counter.incrementAndGet(); return new String(TEST_VALUE_2); }); ticker.advance(60, TimeUnit.SECONDS); cache.cleanup(); assertEquals(TEST_VALUE_1, res); assertEquals(0, counter.get()); }
public static void cache(String key, MapJoinTableContainer tableContainer) { TABLE_CONTAINER_CACHE.put(key, tableContainer); }