Package javax.cache
Interface CacheConfiguration<K,V>
-
- Type Parameters:
K- the type of keys maintained by this cacheV- the type of cached values
- All Known Implementing Classes:
CacheConfigurationImpl
public interface CacheConfiguration<K,V>A value object for cache configuration. A Cache may be constructed byCacheManagerusing 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 its 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 inCacheBuilder.- Since:
- 1.0
- Author:
- Greg Luck, Yannis Cosmadopoulos
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classCacheConfiguration.DurationA time duration.static classCacheConfiguration.ExpiryTypeType of Expiry
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CacheLoader<K,? extends V>getCacheLoader()Gets the registeredCacheLoader, if any.CacheWriter<? super K,? super V>getCacheWriter()Gets the registeredCacheWriter, if any.CacheConfiguration.DurationgetExpiry(CacheConfiguration.ExpiryType type)Gets the cache's time to live setting,Sets how long cache entries should live.IsolationLevelgetTransactionIsolationLevel()Gets the transaction isolation level.ModegetTransactionMode()Gets the transaction mode.booleanisReadThrough()Whether the cache is a read-through cache.booleanisStatisticsEnabled()Checks whether statistics collection is enabled in this cache.booleanisStoreByValue()Whether storeByValue (true) or storeByReference (false).booleanisTransactionEnabled()Checks whether transaction are enabled for this cache.booleanisWriteThrough()Whether the cache is a write-through cache.voidsetStatisticsEnabled(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 onCache.get(Object)and {@link Cache#getAll(java.util.Set}. 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:- if the key is mutated, then the key may not be retrievable or removable
- if the value is mutated, then all threads in the JVM can potentially observe those mutations, subject to the normal Java Memory Model rules.
- 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.NONEif this cache is not transactional.
-
getTransactionMode
Mode getTransactionMode()
Gets the transaction mode.- Returns:
- the the mode of the cache.
Mode.NONEif this cache is not transactional.
-
getCacheLoader
CacheLoader<K,? extends V> getCacheLoader()
Gets the registeredCacheLoader, if any.- Returns:
- the
CacheLoaderor null if none has been set.
-
getCacheWriter
CacheWriter<? super K,? super V> getCacheWriter()
Gets the registeredCacheWriter, if any.- Returns:
- the
CacheWriteror null if none has been set.
-
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 isCacheConfiguration.Duration.ETERNAL.- Parameters:
type- the type of the expiration- Returns:
- how long, in milliseconds, the specified units, the entry should live. 0 means eternal.
-
-