javax.cache
Interface CacheConfiguration


public interface CacheConfiguration

Information on how a cache is configured.

A Cache may be constructed by CacheManager using a configuration instance.

At runtime it is used by javax.cache to decide how to behave. For example the behaviour of put will vary depending on whether the cache is write-through.

Finally, a cache makes it's configuration visible via this interface. Only those configurations which can be changed at runtime (if supported by the underlying implementation) have setters in this interface. Those that can only be set prior to cache construction have setters in CacheBuilder.

Since:
1.0
Author:
Greg Luck, Yannis Cosmadopoulos

Nested Class Summary
static class CacheConfiguration.Duration
          A time duration.
static class CacheConfiguration.ExpiryType
          Type of Expiry
 
Method Summary
 CacheLoader getCacheLoader()
          Gets the registered CacheLoader, if any.
 CacheWriter getCacheWriter()
          Gets the registered CacheWriter, if any.
 CacheConfiguration.Duration getExpiry(CacheConfiguration.ExpiryType type)
          Gets the cache's time to live setting,Sets how long cache entries should live.
 IsolationLevel getTransactionIsolationLevel()
          Gets the transaction isolation level.
 Mode getTransactionMode()
          Gets the transaction mode.
 boolean isReadThrough()
          Whether the cache is a read-through cache.
 boolean isStatisticsEnabled()
          Checks whether statistics collection is enabled in this cache.
 boolean isStoreByValue()
          Whether storeByValue (true) or storeByReference (false).
 boolean isTransactionEnabled()
          Checks whether transaction are enabled for this cache.
 boolean isWriteThrough()
          Whether the cache is a write-through cache.
 void setStatisticsEnabled(boolean enableStatistics)
          Sets whether statistics gathering is enabled on this cache.
 

Method Detail

isReadThrough

boolean isReadThrough()
Whether the cache is a read-through cache. A CacheLoader should be configured for read through caches which is called by the cache for what without the loader would have been misses on Cache.get(Object) and Cache.getAll(java.util.Collection).

Default value is false.

Returns:
true if the cache is read-through

isWriteThrough

boolean isWriteThrough()
Whether the cache is a write-through cache. If so a CacheWriter should be configured.

Default value is false.

Returns:
true if the cache is write-through

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 local heap. If an entry is moved outside local heap it will need to be transformed into a representation. Any mutations that occur after transformation may not be reflected in the cache.

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

setStatisticsEnabled

void setStatisticsEnabled(boolean enableStatistics)
Sets whether statistics gathering is enabled on this cache. This may be changed at runtime.

Parameters:
enableStatistics - true to enable statistics, false to disable.

isTransactionEnabled

boolean isTransactionEnabled()
Checks whether transaction are enabled for this cache.

Default value is false.

Returns:
true if transaction are enabled

getTransactionIsolationLevel

IsolationLevel getTransactionIsolationLevel()
Gets the transaction isolation level.

Returns:
the isolation level. IsolationLevel.NONE if this cache is not transactional.

getTransactionMode

Mode getTransactionMode()
Gets the transaction mode.

Returns:
the the mode of the cache. Mode.NONE if this cache is not transactional.

getCacheLoader

CacheLoader getCacheLoader()
Gets the registered CacheLoader, if any.

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

getCacheWriter

CacheWriter getCacheWriter()
Gets the registered CacheWriter, if any.

Returns:

getExpiry

CacheConfiguration.Duration getExpiry(CacheConfiguration.ExpiryType type)
Gets the cache's time to live setting,Sets how long cache entries should live. If expiry is not set entries are eternal.

Default value is CacheConfiguration.Duration.ETERNAL.

Parameters:
type - the type of the expiration
Returns:
how long, in milliseconds, the specified units, the entry should live. 0 means eternal.


Copyright © 2011. All Rights Reserved.