public Ehcache(CacheConfiguration<K, V> configuration, final Store<K, V> store, ResilienceStrategy<K, V> resilienceStrategy, CacheEventDispatcher<K, V> eventDispatcher, Logger logger, CacheLoaderWriter<? super K, V> cacheLoaderWriter) { super(new EhcacheRuntimeConfiguration<>(configuration), store, resilienceStrategy, eventDispatcher, logger, new StatusTransitioner(logger)); this.cacheLoaderWriter = cacheLoaderWriter; }
/** * {@inheritDoc} */ @Override public Iterator<Entry<K, V>> iterator() { statusTransitioner.checkAvailable(); return new CacheEntryIterator(false); }
/** * {@inheritDoc} */ @Override public void destroy() throws CachePersistenceException { StatusTransitioner.Transition st = statusTransitioner.maintenance(); try { st.succeeded(); } catch (Throwable t) { throw st.failed(t); } destroyInternal(); // Exit maintenance mode once #934 is solved // statusTransitioner.exitMaintenance().succeeded(); }
/** * {@inheritDoc} */ @Override public V get(K key) throws CacheLoadingException { return cache.get(key); }
/** * {@inheritDoc} */ @Override public void putAll(Map<? extends K, ? extends V> entries) throws BulkCacheWritingException { cache.putAll(entries); }
/** * {@inheritDoc} */ @Override public void removeAll(Set<? extends K> keys) throws BulkCacheWritingException { cache.removeAll(keys); }
/** * {@inheritDoc} */ @Override public V replace(K key, V value) throws CacheLoadingException, CacheWritingException { return cache.replace(key, value); }
protected boolean newValueAlreadyExpired(K key, V oldValue, V newValue) { return newValueAlreadyExpired(logger, runtimeConfiguration.getExpiryPolicy(), key, oldValue, newValue); }
/** * {@inheritDoc} */ @Override public void init() { cache.init(); }
/** * {@inheritDoc} */ @Override public Map<K, V> getAll(Set<? extends K> keys) throws BulkCacheLoadingException { return cache.getAll(keys); }
/** * {@inheritDoc} */ @Override public Iterator<Entry<K, V>> iterator() { return cache.iterator(); }
/** * {@inheritDoc} */ @Override public void addHook(LifeCycled hook) { statusTransitioner.addHook(hook); }
/** * {@inheritDoc} */ @Override public Status getStatus() { return statusTransitioner.currentStatus(); }
/** * {@inheritDoc} */ @Override public void remove(K key) throws CacheWritingException { removeInternal(key); // ignore return value; }
protected static void checkNonNull(Object... things) { for (Object thing : things) { checkNonNull(thing); } }
/** * {@inheritDoc} * <p> * This method is implemented as * <code>this.{@link Store#getAndCompute(Object, BiFunction)} (keys, mappingFunction, () -> { returns true; })</code> */ @Override public ValueHolder<String> getAndCompute(final String key, final BiFunction<? super String, ? super String, ? extends String> mappingFunction) throws StoreAccessException { return this.computeAndGet(key, mappingFunction, REPLACE_EQUAL_TRUE, INVOKE_WRITER_FALSE); }
/** * Creates a new {@code Ehcache} based on the provided parameters. * * @param configuration the cache configuration * @param store the store to use * @param eventDispatcher the event dispatcher * @param logger the logger */ public Ehcache(CacheConfiguration<K, V> configuration, final Store<K, V> store, ResilienceStrategy<K, V> resilienceStrategy, CacheEventDispatcher<K, V> eventDispatcher, Logger logger) { this(new EhcacheRuntimeConfiguration<>(configuration), store, resilienceStrategy, eventDispatcher, logger, new StatusTransitioner(logger), null); }