@Test void testCache() { final TrellisCache<String, String> cache = new TrellisCache<>(newBuilder().maximumSize(5).build()); assertEquals("longer", cache.get("long", x -> x + "er"), "Incorrect cache response!"); }
@Override public V get(final K key, final Function<K, V> mapper) { try { return cache.get(key, () -> mapper.apply(key)); } catch (final ExecutionException ex) { throw new TrellisRuntimeException("Error fetching " + key + " from cache", ex); } }
TrellisCache implements CacheService<K, V> { @Override public V get(final K key, final Function<K, V> mapper) { try { return cache.get(key, () -> mapper.apply(key)); } catch (final ExecutionException ex) { throw new TrellisRuntimeException("Error fetching " + key + " from cache", ex); } } }
TrellisCache implements CacheService<K, V> { @Override public V get(final K key, final Function<K, V> mapper) { try { return cache.get(key, () -> mapper.apply(key)); } catch (final ExecutionException ex) { throw new TrellisRuntimeException("Error fetching " + key + " from cache", ex); } } TrellisCache(final Cache<K, V> cache); }
TrellisCache implements CacheService<K, V> { @Override public V get(final K key, final Function<K, V> mapper) { try { return cache.get(key, () -> mapper.apply(key)); } catch (final ExecutionException ex) { throw new TrellisRuntimeException("Error fetching " + key + " from cache", ex); } } TrellisCache(final Cache<K, V> cache); @Override V get(final K key, final Function<K, V> mapper); }
TrellisCache implements CacheService<K, V> { @Override public V get(final K key, final Function<K, V> mapper) { try { return cache.get(key, () -> mapper.apply(key)); } catch (final ExecutionException ex) { throw new TrellisRuntimeException("Error fetching " + key + " from cache", ex); } } TrellisCache(final Cache<K, V> cache); @Override V get(final K key, final Function<K, V> mapper);  }