org.ehcache.spi.cache.tiering
Interface CachingTier<K,V>

All Superinterfaces:
ConfigurationChangeSupport
All Known Subinterfaces:
HigherCachingTier<K,V>
All Known Implementing Classes:
CompoundCachingTier, OnHeapStore

public interface CachingTier<K,V>
extends ConfigurationChangeSupport

Caching tier, according to Montreal design.


Nested Class Summary
static interface CachingTier.InvalidationListener<K,V>
          Caching tier invalidation listener.
static interface CachingTier.Provider
           
 
Method Summary
 void clear()
          Empty out the caching store.
 Store.ValueHolder<V> getOrComputeIfAbsent(K key, Function<K,Store.ValueHolder<V>> source)
          Either return the value holder currently in the caching tier, or compute and store it when it isn't present.
 void invalidate(K key)
          Remove a mapping.
 void setInvalidationListener(CachingTier.InvalidationListener<K,V> invalidationListener)
          Set the caching tier's invalidation listener.
 
Methods inherited from interface org.ehcache.spi.cache.ConfigurationChangeSupport
getConfigurationChangeListeners
 

Method Detail

getOrComputeIfAbsent

Store.ValueHolder<V> getOrComputeIfAbsent(K key,
                                          Function<K,Store.ValueHolder<V>> source)
                                          throws CacheAccessException
Either return the value holder currently in the caching tier, or compute and store it when it isn't present. Note that in case of expired value holders null will be returned and the mapping will be invalidated.

Parameters:
key - the key.
source - the function that computes the value.
Returns:
the value holder, or null.
Throws:
CacheAccessException

invalidate

void invalidate(K key)
                throws CacheAccessException
Remove a mapping.

Parameters:
key - the key.
Throws:
CacheAccessException

clear

void clear()
           throws CacheAccessException
Empty out the caching store.

Throws:
CacheAccessException

setInvalidationListener

void setInvalidationListener(CachingTier.InvalidationListener<K,V> invalidationListener)
Set the caching tier's invalidation listener. The invalidation listener can only be set once.

Parameters:
invalidationListener - the listener.
Throws:
java.lang.IllegalStateException - if the invalidation listener is already set.