Package com.scaleout.client.caching
Class CacheBuilder<K,V>
java.lang.Object
com.scaleout.client.caching.CacheBuilder<K,V>
- Type Parameters:
K
- the key type. Must be int, string, byte[], UUID or provide a customKeyEncoder
.V
- the value type.
The
CacheBuilder
is used to instantiate a typed cache connected to a ScaleOut in-memory data grid.-
Constructor Summary
ConstructorDescriptionCacheBuilder
(GridConnection connection, String cacheName, KeyEncoder<K> keyEncoder, Class<K> keyClass) Instantiates a newCacheBuilder
instance.CacheBuilder
(GridConnection connection, String cacheName, KeyEncoder<K> keyEncoder, Class<K> keyClass, Properties properties) Instantiates a newCacheBuilder
instance.CacheBuilder
(GridConnection connection, String cacheName, Class<K> keyClass) Instantiates a newCacheBuilder
instance.CacheBuilder
(GridConnection connection, String cacheName, Class<K> keyClass, Properties properties) Instantiates a newCacheBuilder
instance. -
Method Summary
Modifier and TypeMethodDescriptionaddRemoteStoreName
(String remoteStoreName) Set the remote store name for GeoServerPull.addRemoteStoreNames
(List<String> remoteStoreNames) Set remote store names to use for GeoServerPull.backingStoreEventInterval
(Duration interval) The interval theBackingStoreMode
will use.TheBackingStoreMode
theCache
will use.build()
Instantiates aCache
connected to ScaleOut via theGridConnection
.clientCache
(ClientCache<K, V> clientCache) Assign a custom client cache implementation to thisCache
.clientCacheCoherencyIntervalMs
(long clientCacheCoherencyIntervalMs) The client cache will return the object if the coherency interval has not elapsed.clientCacheEntryWeigher
(ClientCacheEntryWeigher<K, V> weigher) TheClientCacheEntryWeigher
theClientCache
will use.clientCacheOptions
(ClientCacheOptions clientCacheOptions) TheClientCacheOptions
theClientCache
will use.clientCacheSize
(int size) The size of theClientCache
.customSerialization
(CacheSerializer<V> valueSerializer, CacheDeserializer<V> valueDeserializer) Disables the in-memory string key cache.geoServerCoherencyInterval
(Duration interval) Note, requires GeoServer Pro enabled license.Note,GeoServerCoherencyPolicy.Poll
andGeoServerCoherencyPolicy.Notify
requires GeoServer Pro enabled license.Note, requires GeoServer Pro enabled license.TheGeoServerPushPolicy
theCache
will use.TheGeoServerReadMode
theCache
will use.Retrieve theClientCache
.long
Retrieve the client cache coherency interval in MsRetrieve theClientCacheOptions
theClientCache
will use.int
Retrieve the size of theClientCache
.Retrieve theClientCacheEntryWeigher
theClientCache
will use.Retrieve theGridConnection
theCache
will use.Retrieve theCreatePolicy
theCache
will use.Retrieve theCacheDeserializer
theCache
will useRetrieve theGeoServerReadMode
theCache
will use.Retrieve the key class.Retrieve theKeyEncoder
theCache
will use to encode keys.int
Retrieve the max read through attempts.int
Retrieve the max register remote store attempts.getName()
Retrieve the name of theCache
this CacheBuilder will create.Retrieve theReadPolicy
theCache
will use.Retrieve the read through retry interval.Retrieve the register remote store interval.Retrieve the remote store names.Retrieve theCacheSerializer
theCache
will useobjectTimeout
(Duration objectTimeout) The timeout for objects stored in the ScaleOutCache
.objectTimeoutType
(TimeoutType timeoutType) TheTimeoutType
theCache
will use.preemptionPriority
(PreemptionPriority priority) ThePreemptionPriority
theCache
will use.Tell the ScaleOut StateServer service to raise events for read through.setMaxReadThroughAttempts
(int attempts) Specify the number of max read through attempts.setMaxRegisterRemoteStoreNameAttempts
(int attempts) Specifies the number of attempts to retry setting the remote store.setReadThroughRetryInterval
(Duration interval) Specify the amount of time the client will wait during a read through attempt.setRegisterRemoteStoreRetryInterval
(Duration interval) Specifies the number of attempts to retry setting the remote store.boolean
Check to see if service events should raise an event for read through
-
Constructor Details
-
CacheBuilder
Instantiates a new
CacheBuilder
instance.GridConnection is instantiated through the static method,
GridConnection.connect(String)
.The provided
cacheName
is used to logically separateCache
instances.- Parameters:
connection
- an existing grid connectioncacheName
- the cache name to usekeyClass
- the key class. Note, must be Integer.class, byte[].class, UUID.class, or String.class
-
CacheBuilder
public CacheBuilder(GridConnection connection, String cacheName, KeyEncoder<K> keyEncoder, Class<K> keyClass) Instantiates a newCacheBuilder
instance. GridConnection is instantiated through the static method,GridConnection.connect(String)
.- Parameters:
connection
- an existingGridConnection
.cacheName
- the cache name to use.keyEncoder
- theKeyEncoder
.keyClass
- the key class.
-
CacheBuilder
public CacheBuilder(GridConnection connection, String cacheName, KeyEncoder<K> keyEncoder, Class<K> keyClass, Properties properties) Instantiates a newCacheBuilder
instance. GridConnection is instantiated through the static method,GridConnection.connect(String)
.- Parameters:
connection
- an existingGridConnection
.cacheName
- the cache name to use.keyEncoder
- theKeyEncoder
.keyClass
- the key class.properties
- the properties to initialize thisCacheBuilder
from.
-
CacheBuilder
public CacheBuilder(GridConnection connection, String cacheName, Class<K> keyClass, Properties properties) Instantiates a newCacheBuilder
instance. GridConnection is instantiated through the static method,GridConnection.connect(String)
.- Parameters:
connection
- an existingGridConnection
.cacheName
- the cache name to use.keyClass
- the key class.properties
- the properties to initialize thisCacheBuilder
from.
-
-
Method Details
-
getName
Retrieve the name of theCache
this CacheBuilder will create.- Returns:
- the name of the
Cache
.
-
getConnection
Retrieve theGridConnection
theCache
will use.- Returns:
- the
GridConnection
.
-
getKeyEncoder
Retrieve theKeyEncoder
theCache
will use to encode keys.- Returns:
- the
KeyEncoder
.
-
getSerializer
Retrieve theCacheSerializer
theCache
will use- Returns:
- the
CacheSerializer
.
-
getDeserializer
Retrieve theCacheDeserializer
theCache
will use- Returns:
- the
CacheDeserializer
.
-
getCreatePolicy
Retrieve theCreatePolicy
theCache
will use.- Returns:
- the
CreatePolicy
.
-
getReadPolicy
Retrieve theReadPolicy
theCache
will use.- Returns:
- the
ReadPolicy
.
-
getGeoServerReadMode
Retrieve theGeoServerReadMode
theCache
will use.- Returns:
- the
GeoServerReadMode
.
-
getClientCache
Retrieve theClientCache
.- Returns:
- the client cache.
-
getClientCacheWeigher
Retrieve theClientCacheEntryWeigher
theClientCache
will use.- Returns:
- the
ClientCacheEntryWeigher
.
-
getClientCacheSize
public int getClientCacheSize()Retrieve the size of theClientCache
.- Returns:
- the size of the
ClientCache
.
-
getClientCacheOptions
Retrieve theClientCacheOptions
theClientCache
will use.- Returns:
- the
ClientCacheOptions
.
-
getClientCacheCoherencyIntervalMs
public long getClientCacheCoherencyIntervalMs()Retrieve the client cache coherency interval in Ms- Returns:
- the client cache coherency interval
-
getKeyClass
Retrieve the key class.- Returns:
- the key class.
-
getRemoteStoreNames
Retrieve the remote store names.- Returns:
- the remote store names.
-
useAsyncReadThrough
public boolean useAsyncReadThrough()Check to see if service events should raise an event for read through- Returns:
- true if service events should raise an event for read through, false otherwise.
-
getMaxReadThroughAttempts
public int getMaxReadThroughAttempts()Retrieve the max read through attempts.- Returns:
- the max read through attempts.
-
getMaxRegisterRemoteStoreAttempts
public int getMaxRegisterRemoteStoreAttempts()Retrieve the max register remote store attempts.- Returns:
- the max register remote store attempts.
-
getReadThroughRetryInterval
Retrieve the read through retry interval.- Returns:
- the read through retry interval.
-
getRegisterRemoteStoreRetryInterval
Retrieve the register remote store interval.- Returns:
- the register remote store interval.
-
customSerialization
public CacheBuilder<K,V> customSerialization(CacheSerializer<V> valueSerializer, CacheDeserializer<V> valueDeserializer) - Parameters:
valueSerializer
- the value serializer.valueDeserializer
- the value deserializer.- Returns:
- this
CacheBuilder
.
-
geoServerCoherencyPolicy
Note,GeoServerCoherencyPolicy.Poll
andGeoServerCoherencyPolicy.Notify
requires GeoServer Pro enabled license. Set theGeoServerCoherencyPolicy
theCache
will use.- Parameters:
policy
- theGeoServerCoherencyPolicy
.- Returns:
- this
CacheBuilder
.
-
geoServerCoherencyInterval
Note, requires GeoServer Pro enabled license. IfGeoServerCoherencyPolicy.Poll
is used, set the interval for GeoServer polling operations.- Parameters:
interval
- the interval to wait for polling operations.- Returns:
- this
CacheBuilder
.
-
geoServerPullPolicy
Note, requires GeoServer Pro enabled license. TheGeoServerPullPolicy
theCache
will use.- Parameters:
policy
- theGeoServerPullPolicy
.- Returns:
- this
CacheBuilder
.
-
geoServerPushPolicy
TheGeoServerPushPolicy
theCache
will use.- Parameters:
policy
- theGeoServerPullPolicy
.- Returns:
- this
CacheBuilder
.
-
geoServerReadMode
TheGeoServerReadMode
theCache
will use.- Parameters:
mode
- theGeoServerReadMode
.- Returns:
- this
CacheBuilder
.
-
preemptionPriority
ThePreemptionPriority
theCache
will use.- Parameters:
priority
- thePreemptionPriority
.- Returns:
- this
CacheBuilder
.
-
objectTimeout
The timeout for objects stored in the ScaleOutCache
.- Parameters:
objectTimeout
- the timeout.- Returns:
- this
CacheBuilder
.
-
objectTimeoutType
TheTimeoutType
theCache
will use.- Parameters:
timeoutType
- theTimeoutType
.- Returns:
- this
CacheBuilder
.
-
backingStoreMode
TheBackingStoreMode
theCache
will use.- Parameters:
mode
- theBackingStoreMode
.- Returns:
- this
CacheBuilder
.
-
backingStoreEventInterval
The interval theBackingStoreMode
will use. TODO replace with BackingStore class when finished- Parameters:
interval
- the interval.- Returns:
- this
CacheBuilder
.
-
clientCacheEntryWeigher
TheClientCacheEntryWeigher
theClientCache
will use.- Parameters:
weigher
- theClientCacheEntryWeigher
.- Returns:
- this
CacheBuilder
.
-
clientCacheSize
The size of theClientCache
.- Parameters:
size
- the size.- Returns:
- this
CacheBuilder
.
-
clientCache
Assign a custom client cache implementation to thisCache
.- Parameters:
clientCache
- the client cache implemenation.- Returns:
- this
CacheBuilder
-
clientCacheOptions
TheClientCacheOptions
theClientCache
will use.- Parameters:
clientCacheOptions
- theClientCacheOptions
.- Returns:
- this
CacheBuilder
.
-
clientCacheCoherencyIntervalMs
The client cache will return the object if the coherency interval has not elapsed. Default is 0 (disabled).- Parameters:
clientCacheCoherencyIntervalMs
- the coherency interval- Returns:
- this
CacheBuilder
.
-
raiseServiceEventForReadThrough
Tell the ScaleOut StateServer service to raise events for read through.- Returns:
- this builder.
-
addRemoteStoreNames
Set remote store names to use for GeoServerPull.- Parameters:
remoteStoreNames
- a list of the remote store names.- Returns:
- this.
-
addRemoteStoreName
Set the remote store name for GeoServerPull.- Parameters:
remoteStoreName
- the remote store name.- Returns:
- this.
-
setMaxReadThroughAttempts
Specify the number of max read through attempts. A read through attempt is performed when a value factory is supplied toServiceEvents.setLoadObjectHandler(Cache, ValueFactory)
or when usingCache.readOrAdd(Object, ValueFactory, ReadPolicy)
andCache.readOrAddAsync(Object, ValueFactory, ReadPolicy)
.- Parameters:
attempts
- number of attempts.- Returns:
- this.
-
setReadThroughRetryInterval
Specify the amount of time the client will wait during a read through attempt. A read through attempt is performed when a value factory is supplied toServiceEvents.setLoadObjectHandler(Cache, ValueFactory)
or when usingCache.readOrAdd(Object, ValueFactory, ReadPolicy)
andCache.readOrAddAsync(Object, ValueFactory, ReadPolicy)
.- Parameters:
interval
- number of attempts.- Returns:
- this.
-
setMaxRegisterRemoteStoreNameAttempts
Specifies the number of attempts to retry setting the remote store. If an operation which requires a remote store (Cache.readAndLock(Object)
) is attempted, and no remote store has been set, the client will automatically attempt to reset the remote store.- Parameters:
attempts
- the attempts.- Returns:
- this builder.
-
setRegisterRemoteStoreRetryInterval
Specifies the number of attempts to retry setting the remote store. If an operation which requires a remote store (Cache.readAndLock(Object)
) is attempted, and no remote store has been set, the client will automatically attempt to reset the remote store.- Parameters:
interval
- the interval- Returns:
- this builder.
-
disableLocalStringKeyCaching
Disables the in-memory string key cache.- Returns:
- this builder.
-
build
Instantiates aCache
connected to ScaleOut via theGridConnection
.- Returns:
- the
Cache
.
-