javax.cache
Interface Configuration<K,V>

Type Parameters:
K - the type of keys maintained the cache
V - the type of cached values
All Known Implementing Classes:
MutableConfiguration

public interface Configuration<K,V>

A read-only representation of a Cache configuration.

The properties provided by instances of this interface are used by CacheManagers to configure Caches.

Implementations of this interface must always override #hashCode() and #equals(Object) as Configurations are often compared at runtime.

Since:
1.0
Author:
Greg Luck, Yannis Cosmadopoulos, Brian Oliver

Nested Class Summary
static class Configuration.Duration
          A time duration.
 
Method Summary
 Iterable<CacheEntryListenerRegistration<? super K,? super V>> getCacheEntryListenerRegistrations()
          Obtains the CacheEntryListenerRegistrations for CacheEntryListeners to be configured on a Cache.
 CacheLoader<K,? extends V> getCacheLoader()
          Gets the registered CacheLoader, if any.
 CacheWriter<? super K,? super V> getCacheWriter()
          Gets the registered CacheWriter, if any.
 ExpiryPolicy<? super K,? super V> getExpiryPolicy()
          Gets the ExpiryPolicy to be used for caches.
 IsolationLevel getTransactionIsolationLevel()
          Gets the transaction isolation level.
 Mode getTransactionMode()
          Gets the transaction mode.
 boolean isReadThrough()
          Determines if a Cache should operate in "read-through" mode.
 boolean isStatisticsEnabled()
          Checks whether statistics collection is enabled in this cache.
 boolean isStoreByValue()
          Whether storeByValue (true) or storeByReference (false).
 boolean isTransactionsEnabled()
          Checks whether transactions are enabled for this cache.
 boolean isWriteThrough()
          Determines if a Cache should operate in "write-through" mode.
 

Method Detail

isReadThrough

boolean isReadThrough()
Determines if a Cache should operate in "read-through" mode.

When in "read-through" mode, cache misses that occur due to cache entries not existing as a result of performing a "get" call via one of Cache.get(Object), Cache.getAll(java.util.Set), Cache.getAndRemove(Object) and/or Cache.getAndReplace(Object, Object) will appropriately cause the configured CacheLoader to be invoked.

The default value is false.

Returns:
true when a Cache is in "read-through" mode.
See Also:
getCacheLoader()

isWriteThrough

boolean isWriteThrough()
Determines if a Cache should operate in "write-through" mode.

When in "write-through" mode, cache updates that occur as a result of performing "put" operations called via one of Cache.put(Object, Object), Cache.getAndRemove(Object), Cache.removeAll(), Cache.getAndPut(Object, Object) Cache.getAndRemove(Object), Cache.getAndReplace(Object, Object), Cache.invokeEntryProcessor(Object, javax.cache.Cache.EntryProcessor) will appropriately cause the configured CacheWriter to be invoked.

The default value is false.

Returns:
true when a Cache is in "write-through" mode.
See Also:
getCacheWriter()

isStoreByValue

boolean isStoreByValue()
Whether storeByValue (true) or storeByReference (false). When true, both keys and values are stored by value.

When false, both keys and values are stored by reference. Caches stored by reference are capable of mutation by any threads holding the reference. The effects are:

Storage by reference only applies to the local heap. If an entry is moved off heap it will need to be transformed into a representation. Any mutations that occur after transformation may not be reflected in the cache.

When a cache is storeByValue, any mutation to the key or value does not affect the key of value stored in the cache.

The default value is true.

Returns:
true if the cache is store by value

isStatisticsEnabled

boolean isStatisticsEnabled()
Checks whether statistics collection is enabled in this cache.

The default value is false.

Returns:
true if statistics collection is enabled

isTransactionsEnabled

boolean isTransactionsEnabled()
Checks whether transactions are enabled for this cache.

Note that in a transactional cache, entries being mutated within a transaction cannot be expired by the cache.

The default value is false.

Returns:
true if transaction are enabled

getTransactionIsolationLevel

IsolationLevel getTransactionIsolationLevel()
Gets the transaction isolation level.

The default value is IsolationLevel.NONE.

Returns:
the isolation level.

getTransactionMode

Mode getTransactionMode()
Gets the transaction mode.

The default value is Mode.NONE.

Returns:
the the mode of the cache.

getCacheEntryListenerRegistrations

Iterable<CacheEntryListenerRegistration<? super K,? super V>> getCacheEntryListenerRegistrations()
Obtains the CacheEntryListenerRegistrations for CacheEntryListeners to be configured on a Cache.

Returns:
an Iterable over the CacheEntryListenerRegistrations

getCacheLoader

CacheLoader<K,? extends V> getCacheLoader()
Gets the registered CacheLoader, if any.

A CacheLoader should be configured for "Read Through" caches to load values when a cache miss occurs using either the Cache.get(Object) and/or Cache#getAll(java.util.Set methods.

The default value is null.

Returns:
the CacheLoader or null if none has been set.

getCacheWriter

CacheWriter<? super K,? super V> getCacheWriter()
Gets the registered CacheWriter, if any.

The default value is null.

Returns:
the CacheWriter or null if none has been set.

getExpiryPolicy

ExpiryPolicy<? super K,? super V> getExpiryPolicy()
Gets the ExpiryPolicy to be used for caches.

The default value is ExpiryPolicy#DEFAULT.

Returns:
the ExpiryPolicy (must not be null)


Copyright © 2013. All Rights Reserved.