@Test void should_be_set_when_callable_key_is_not_exists() throws Exception { doReturn(null).when(source).get("1"); doReturn(2).when(callable).call(); assertThat(cache.get(1, callable)).isEqualTo(2); verify(source).set("1", 2); }
@SuppressWarnings("unchecked") @Override public <T> T get(final Object key, final Callable<T> valueLoader) { final String candidateKey = toEVCacheKey(key); final Lock lock = locks.get(candidateKey); lock.lock(); try { final Object cached = doGet(candidateKey); if (nonNull(cached)) { return (T) fromStoreValue(cached); } final T value = valueLoader.call(); doSet(candidateKey, value); return (T) fromStoreValue(value); } catch (final Exception ex) { throw new ValueRetrievalException(key, valueLoader, ex); } finally { lock.unlock(); } }
EVCacheImpl extends AbstractValueAdaptingCache implements EVCache { @SuppressWarnings("unchecked") @Override public <T> T get(final Object key, final Callable<T> valueLoader) { final String candidateKey = toEVCacheKey(key); final Lock lock = locks.get(candidateKey); lock.lock(); try { final Object cached = doGet(candidateKey); if (nonNull(cached)) { return (T) fromStoreValue(cached); } final T value = valueLoader.call(); doSet(candidateKey, value); return (T) fromStoreValue(value); } catch (final Exception ex) { throw new ValueRetrievalException(key, valueLoader, ex); } finally { lock.unlock(); } } }
EVCacheImpl extends AbstractValueAdaptingCache implements EVCache { @SuppressWarnings("unchecked") @Override public <T> T get(final Object key, final Callable<T> valueLoader) { final String candidateKey = toEVCacheKey(key); final Lock lock = locks.get(candidateKey); lock.lock(); try { final Object cached = doGet(candidateKey); if (nonNull(cached)) { return (T) fromStoreValue(cached); } final T value = valueLoader.call(); doSet(candidateKey, value); return (T) fromStoreValue(value); } catch (final Exception ex) { throw new ValueRetrievalException(key, valueLoader, ex); } finally { lock.unlock(); } } EVCacheImpl(final String name,
                       final com.netflix.evcache.EVCache cache,
                       final boolean allowNullValues,
                       final int striped,
                       final boolean deleteWhitespaceKey); }
EVCacheImpl extends AbstractValueAdaptingCache implements EVCache { @SuppressWarnings("unchecked") @Override public <T> T get(final Object key, final Callable<T> valueLoader) { final String candidateKey = toEVCacheKey(key); final Lock lock = locks.get(candidateKey); lock.lock(); try { final Object cached = doGet(candidateKey); if (nonNull(cached)) { return (T) fromStoreValue(cached); } final T value = valueLoader.call(); doSet(candidateKey, value); return (T) fromStoreValue(value); } catch (final Exception ex) { throw new ValueRetrievalException(key, valueLoader, ex); } finally { lock.unlock(); } } EVCacheImpl(final String name,
                       final com.netflix.evcache.EVCache cache,
                       final boolean allowNullValues,
                       final int striped,
                       final boolean deleteWhitespaceKey); @Override String getName(); @Override com.netflix.evcache.EVCache getNativeCache(); @SuppressWarnings("unchecked") @Override T get(final Object key, final Callable<T> valueLoader); @Override void put(final Object key, final Object value); @Override ValueWrapper putIfAbsent(final Object key, final Object value); @Override void evict(final Object key); @Override void clear(); }
EVCacheImpl extends AbstractValueAdaptingCache implements EVCache { @SuppressWarnings("unchecked") @Override public <T> T get(final Object key, final Callable<T> valueLoader) { final String candidateKey = toEVCacheKey(key); final Lock lock = locks.get(candidateKey); lock.lock(); try { final Object cached = doGet(candidateKey); if (nonNull(cached)) { return (T) fromStoreValue(cached); } final T value = valueLoader.call(); doSet(candidateKey, value); return (T) fromStoreValue(value); } catch (final Exception ex) { throw new ValueRetrievalException(key, valueLoader, ex); } finally { lock.unlock(); } } EVCacheImpl(final String name,
                       final com.netflix.evcache.EVCache cache,
                       final boolean allowNullValues,
                       final int striped,
                       final boolean deleteWhitespaceKey); @Override String getName(); @Override com.netflix.evcache.EVCache getNativeCache(); @SuppressWarnings("unchecked") @Override T get(final Object key, final Callable<T> valueLoader); @Override void put(final Object key, final Object value); @Override ValueWrapper putIfAbsent(final Object key, final Object value); @Override void evict(final Object key); @Override void clear();  }