Package com.hazelcast.config
Interface CacheConfiguration<K,V>
- Type Parameters:
K
- the type of keyV
- the type of value
- All Superinterfaces:
javax.cache.configuration.CompleteConfiguration<K,
,V> javax.cache.configuration.Configuration<K,
,V> Serializable
- All Known Implementing Classes:
AbstractCacheConfig
,CacheConfig
public interface CacheConfiguration<K,V>
extends javax.cache.configuration.CompleteConfiguration<K,V>
Mutable extension to
CompleteConfiguration
-
Method Summary
Modifier and TypeMethodDescriptionaddCacheEntryListenerConfiguration
(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) Add a configuration for aCacheEntryListener
.removeCacheEntryListenerConfiguration
(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) Remove a configuration for aCacheEntryListener
.setCacheLoaderFactory
(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K, V>> factory) Set theCacheLoader
factory.setCacheWriterFactory
(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheWriter<? super K, ? super V>> factory) Set theCacheWriter
factory.setExpiryPolicyFactory
(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy> factory) Set theFactory
for theExpiryPolicy
.setManagementEnabled
(boolean enabled) Sets whether management is enabled on a cache.setReadThrough
(boolean isReadThrough) Set if read-through caching should be used.setStatisticsEnabled
(boolean enabled) Sets whether statistics gathering is enabled on a cache.setStoreByValue
(boolean isStoreByValue) Set if a configured cache should use store-by-value or store-by-reference semantics.Sets the expected type of keys and values for aCache
configured with thisConfiguration
.setWriteThrough
(boolean isWriteThrough) Set if write-through caching should be used.Methods inherited from interface javax.cache.configuration.CompleteConfiguration
getCacheEntryListenerConfigurations, getCacheLoaderFactory, getCacheWriterFactory, getExpiryPolicyFactory, isManagementEnabled, isReadThrough, isStatisticsEnabled, isWriteThrough
Methods inherited from interface javax.cache.configuration.Configuration
getKeyType, getValueType, isStoreByValue
-
Method Details
-
setTypes
Sets the expected type of keys and values for aCache
configured with thisConfiguration
. Setting both toObject.class
means type-safety checks are not required.This is used by
CacheManager
to ensure that the key and value types are the same as those configured for theCache
prior to returning a requested cache from this method.Implementations may further perform type checking on mutative cache operations and throw a
ClassCastException
if these checks fail.- Parameters:
keyType
- the expected key typevalueType
- the expected value type- Returns:
- the
CacheConfiguration
to permit fluent-style method calls - Throws:
NullPointerException
- should the key or value type benull
- See Also:
-
CacheManager.getCache(String, Class, Class)
-
addCacheEntryListenerConfiguration
CacheConfiguration<K,V> addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) Add a configuration for aCacheEntryListener
.- Parameters:
cacheEntryListenerConfiguration
- theCacheEntryListenerConfiguration
- Returns:
- the
CacheConfiguration
to permit fluent-style method calls - Throws:
IllegalArgumentException
- if the same CacheEntryListenerConfiguration is used more than once
-
removeCacheEntryListenerConfiguration
CacheConfiguration<K,V> removeCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) Remove a configuration for aCacheEntryListener
.- Parameters:
cacheEntryListenerConfiguration
- theCacheEntryListenerConfiguration
to remove- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-
setCacheLoaderFactory
CacheConfiguration<K,V> setCacheLoaderFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K, V>> factory) Set theCacheLoader
factory.- Parameters:
factory
- theCacheLoader
Factory
- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-
setCacheWriterFactory
CacheConfiguration<K,V> setCacheWriterFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheWriter<? super K, ? super V>> factory) Set theCacheWriter
factory.- Parameters:
factory
- theCacheWriter
Factory
- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-
setExpiryPolicyFactory
CacheConfiguration<K,V> setExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy> factory) Set theFactory
for theExpiryPolicy
. Ifnull
is specified the defaultExpiryPolicy
is used.- Parameters:
factory
- theExpiryPolicy
Factory
- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-
setReadThrough
Set if read-through caching should be used.It is an invalid configuration to set this to
true
without specifying aCacheLoader
Factory
.- Parameters:
isReadThrough
-true
if read-through is required,false
otherwise- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-
setWriteThrough
Set if write-through caching should be used.It is an invalid configuration to set this to
true
without specifying aCacheWriter
Factory
.- Parameters:
isWriteThrough
-true
if write-through is required,false
otherwise- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-
setStoreByValue
Set if a configured cache should use store-by-value or store-by-reference semantics.- Parameters:
isStoreByValue
-true
if store-by-value is required,false
for store-by-reference- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-
setStatisticsEnabled
Sets whether statistics gathering is enabled on a cache.Statistics may be enabled or disabled at runtime via
CacheManager.enableStatistics(String, boolean)
.- Parameters:
enabled
-true
to enable statistics,false
to disable- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-
setManagementEnabled
Sets whether management is enabled on a cache.Management may be enabled or disabled at runtime via
CacheManager.enableManagement(String, boolean)
.- Parameters:
enabled
-true
to enable management,false
to disable- Returns:
- the
CacheConfiguration
to permit fluent-style method calls
-