K
- the key type. Must be int, string, byte[], UUID or provide a custom KeyEncoder
.V
- the value type.public class CacheBuilder<K,V>
extends java.lang.Object
CacheBuilder
is used to instantiate a typed cache connected to a ScaleOut in-memory data grid.Constructor and Description |
---|
CacheBuilder(GridConnection connection,
java.lang.String cacheName,
java.lang.Class<K> keyClass)
Instantiates a new
CacheBuilder instance. |
CacheBuilder(GridConnection connection,
java.lang.String cacheName,
java.lang.Class<K> keyClass,
java.util.Properties properties)
Instantiates a new
CacheBuilder instance. |
CacheBuilder(GridConnection connection,
java.lang.String cacheName,
KeyEncoder<K> keyEncoder,
java.lang.Class<K> keyClass)
Instantiates a new
CacheBuilder instance. |
CacheBuilder(GridConnection connection,
java.lang.String cacheName,
KeyEncoder<K> keyEncoder,
java.lang.Class<K> keyClass,
java.util.Properties properties)
Instantiates a new
CacheBuilder instance. |
Modifier and Type | Method and Description |
---|---|
CacheBuilder<K,V> |
addRemoteStoreName(java.lang.String remoteStoreName)
Set the remote store name for GeoServerPull.
|
CacheBuilder<K,V> |
addRemoteStoreNames(java.util.List<java.lang.String> remoteStoreNames)
Set remote store names to use for GeoServerPull.
|
CacheBuilder<K,V> |
backingStoreEventInterval(java.time.Duration interval)
The interval the
BackingStoreMode will use. |
CacheBuilder<K,V> |
backingStoreMode(BackingStoreMode mode)
The
BackingStoreMode the Cache will use. |
Cache<K,V> |
build()
Instantiates a
Cache connected to ScaleOut via the GridConnection . |
CacheBuilder<K,V> |
clientCache(ClientCache<K,V> clientCache)
Assign a custom client cache implementation to this
Cache . |
CacheBuilder<K,V> |
clientCacheCoherencyIntervalMs(long clientCacheCoherencyIntervalMs)
The client cache will return the object if the coherency interval has not elapsed.
|
CacheBuilder<K,V> |
clientCacheEntryWeigher(ClientCacheEntryWeigher<K,V> weigher)
The
ClientCacheEntryWeigher the ClientCache will use. |
CacheBuilder<K,V> |
clientCacheOptions(ClientCacheOptions clientCacheOptions)
The
ClientCacheOptions the ClientCache will use. |
CacheBuilder<K,V> |
clientCacheSize(int size)
The size of the
ClientCache . |
CacheBuilder<K,V> |
customSerialization(CacheSerializer<V> valueSerializer,
CacheDeserializer<V> valueDeserializer)
|
CacheBuilder<K,V> |
disableLocalStringKeyCaching()
Disables the in-memory string key cache.
|
CacheBuilder<K,V> |
geoServerCoherencyInterval(java.time.Duration interval)
Note, requires GeoServer Pro enabled license.
|
CacheBuilder<K,V> |
geoServerCoherencyPolicy(GeoServerCoherencyPolicy policy)
Note,
GeoServerCoherencyPolicy.Poll and GeoServerCoherencyPolicy.Notify requires GeoServer Pro enabled license. |
CacheBuilder<K,V> |
geoServerPullPolicy(GeoServerPullPolicy policy)
Note, requires GeoServer Pro enabled license.
|
CacheBuilder<K,V> |
geoServerPushPolicy(GeoServerPushPolicy policy)
The
GeoServerPushPolicy the Cache will use. |
CacheBuilder<K,V> |
geoServerReadMode(GeoServerReadMode mode)
The
GeoServerReadMode the Cache will use. |
ClientCache<K,V> |
getClientCache()
Retrieve the
ClientCache . |
long |
getClientCacheCoherencyIntervalMs()
Retrieve the client cache coherency interval in Ms
|
ClientCacheOptions |
getClientCacheOptions()
Retrieve the
ClientCacheOptions the ClientCache will use. |
int |
getClientCacheSize()
Retrieve the size of the
ClientCache . |
ClientCacheEntryWeigher<K,V> |
getClientCacheWeigher()
Retrieve the
ClientCacheEntryWeigher the ClientCache will use. |
GridConnection |
getConnection()
Retrieve the
GridConnection the Cache will use. |
CreatePolicy |
getCreatePolicy()
Retrieve the
CreatePolicy the Cache will use. |
CacheDeserializer<V> |
getDeserializer()
Retrieve the
CacheDeserializer the Cache will use |
GeoServerReadMode |
getGeoServerReadMode()
Retrieve the
GeoServerReadMode the Cache will use. |
java.lang.Class<K> |
getKeyClass()
Retrieve the key class.
|
KeyEncoder<K> |
getKeyEncoder()
Retrieve the
KeyEncoder the Cache will use to encode keys. |
int |
getMaxReadThroughAttempts()
Retrieve the max read through attempts.
|
int |
getMaxRegisterRemoteStoreAttempts()
Retrieve the max register remote store attempts.
|
java.lang.String |
getName()
Retrieve the name of the
Cache this CacheBuilder will create. |
ReadPolicy |
getReadPolicy()
Retrieve the
ReadPolicy the Cache will use. |
java.time.Duration |
getReadThroughRetryInterval()
Retrieve the read through retry interval.
|
java.time.Duration |
getRegisterRemoteStoreRetryInterval()
Retrieve the register remote store interval.
|
java.util.List<java.lang.String> |
getRemoteStoreNames()
Retrieve the remote store names.
|
CacheSerializer<V> |
getSerializer()
Retrieve the
CacheSerializer the Cache will use |
CacheBuilder<K,V> |
objectTimeout(java.time.Duration objectTimeout)
The timeout for objects stored in the ScaleOut
Cache . |
CacheBuilder<K,V> |
objectTimeoutType(TimeoutType timeoutType)
The
TimeoutType the Cache will use. |
CacheBuilder<K,V> |
preemptionPriority(PreemptionPriority priority)
The
PreemptionPriority the Cache will use. |
CacheBuilder<K,V> |
raiseServiceEventForReadThrough()
Tell the ScaleOut StateServer service to raise events for read through.
|
CacheBuilder<K,V> |
setMaxReadThroughAttempts(int attempts)
Specify the number of max read through attempts.
|
CacheBuilder<K,V> |
setMaxRegisterRemoteStoreNameAttempts(int attempts)
Specifies the number of attempts to retry setting the remote store.
|
CacheBuilder<K,V> |
setReadThroughRetryInterval(java.time.Duration interval)
Specify the amount of time the client will wait during a read through attempt.
|
CacheBuilder<K,V> |
setRegisterRemoteStoreRetryInterval(java.time.Duration interval)
Specifies the number of attempts to retry setting the remote store.
|
boolean |
useAsyncReadThrough()
Check to see if service events should raise an event for read through
|
public CacheBuilder(GridConnection connection, java.lang.String cacheName, java.lang.Class<K> keyClass)
Instantiates a new CacheBuilder
instance.
GridConnection is instantiated through the static method, GridConnection.connect(String)
.
The provided cacheName
is used to logically separate Cache
instances.
connection
- an existing grid connectioncacheName
- the cache name to usekeyClass
- the key class. Note, must be Integer.class, byte[].class, UUID.class, or String.classpublic CacheBuilder(GridConnection connection, java.lang.String cacheName, KeyEncoder<K> keyEncoder, java.lang.Class<K> keyClass)
CacheBuilder
instance.
GridConnection is instantiated through the static method, GridConnection.connect(String)
.connection
- an existing GridConnection
.cacheName
- the cache name to use.keyEncoder
- the KeyEncoder
.keyClass
- the key class.public CacheBuilder(GridConnection connection, java.lang.String cacheName, KeyEncoder<K> keyEncoder, java.lang.Class<K> keyClass, java.util.Properties properties)
CacheBuilder
instance.
GridConnection is instantiated through the static method, GridConnection.connect(String)
.connection
- an existing GridConnection
.cacheName
- the cache name to use.keyEncoder
- the KeyEncoder
.keyClass
- the key class.properties
- the properties to initialize this CacheBuilder
from.public CacheBuilder(GridConnection connection, java.lang.String cacheName, java.lang.Class<K> keyClass, java.util.Properties properties)
CacheBuilder
instance.
GridConnection is instantiated through the static method, GridConnection.connect(String)
.connection
- an existing GridConnection
.cacheName
- the cache name to use.keyClass
- the key class.properties
- the properties to initialize this CacheBuilder
from.public java.lang.String getName()
Cache
this CacheBuilder will create.Cache
.public GridConnection getConnection()
GridConnection
the Cache
will use.GridConnection
.public KeyEncoder<K> getKeyEncoder()
KeyEncoder
the Cache
will use to encode keys.KeyEncoder
.public CacheSerializer<V> getSerializer()
CacheSerializer
the Cache
will useCacheSerializer
.public CacheDeserializer<V> getDeserializer()
CacheDeserializer
the Cache
will useCacheDeserializer
.public CreatePolicy getCreatePolicy()
CreatePolicy
the Cache
will use.CreatePolicy
.public ReadPolicy getReadPolicy()
ReadPolicy
the Cache
will use.ReadPolicy
.public GeoServerReadMode getGeoServerReadMode()
GeoServerReadMode
the Cache
will use.GeoServerReadMode
.public ClientCache<K,V> getClientCache()
ClientCache
.public ClientCacheEntryWeigher<K,V> getClientCacheWeigher()
ClientCacheEntryWeigher
the ClientCache
will use.ClientCacheEntryWeigher
.public int getClientCacheSize()
ClientCache
.ClientCache
.public ClientCacheOptions getClientCacheOptions()
ClientCacheOptions
the ClientCache
will use.ClientCacheOptions
.public long getClientCacheCoherencyIntervalMs()
public java.lang.Class<K> getKeyClass()
public java.util.List<java.lang.String> getRemoteStoreNames()
public boolean useAsyncReadThrough()
public int getMaxReadThroughAttempts()
public int getMaxRegisterRemoteStoreAttempts()
public java.time.Duration getReadThroughRetryInterval()
public java.time.Duration getRegisterRemoteStoreRetryInterval()
public CacheBuilder<K,V> customSerialization(CacheSerializer<V> valueSerializer, CacheDeserializer<V> valueDeserializer)
valueSerializer
- the value serializer.valueDeserializer
- the value deserializer.CacheBuilder
.public CacheBuilder<K,V> geoServerCoherencyPolicy(GeoServerCoherencyPolicy policy)
GeoServerCoherencyPolicy.Poll
and GeoServerCoherencyPolicy.Notify
requires GeoServer Pro enabled license.
Set the GeoServerCoherencyPolicy
the Cache
will use.policy
- the GeoServerCoherencyPolicy
.CacheBuilder
.public CacheBuilder<K,V> geoServerCoherencyInterval(java.time.Duration interval)
GeoServerCoherencyPolicy.Poll
is used, set the interval for GeoServer polling operations.interval
- the interval to wait for polling operations.CacheBuilder
.public CacheBuilder<K,V> geoServerPullPolicy(GeoServerPullPolicy policy)
GeoServerPullPolicy
the Cache
will use.policy
- the GeoServerPullPolicy
.CacheBuilder
.public CacheBuilder<K,V> geoServerPushPolicy(GeoServerPushPolicy policy)
GeoServerPushPolicy
the Cache
will use.policy
- the GeoServerPullPolicy
.CacheBuilder
.public CacheBuilder<K,V> geoServerReadMode(GeoServerReadMode mode)
GeoServerReadMode
the Cache
will use.mode
- the GeoServerReadMode
.CacheBuilder
.public CacheBuilder<K,V> preemptionPriority(PreemptionPriority priority)
PreemptionPriority
the Cache
will use.priority
- the PreemptionPriority
.CacheBuilder
.public CacheBuilder<K,V> objectTimeout(java.time.Duration objectTimeout)
Cache
.objectTimeout
- the timeout.CacheBuilder
.public CacheBuilder<K,V> objectTimeoutType(TimeoutType timeoutType)
TimeoutType
the Cache
will use.timeoutType
- the TimeoutType
.CacheBuilder
.public CacheBuilder<K,V> backingStoreMode(BackingStoreMode mode)
BackingStoreMode
the Cache
will use.mode
- the BackingStoreMode
.CacheBuilder
.public CacheBuilder<K,V> backingStoreEventInterval(java.time.Duration interval)
BackingStoreMode
will use.
TODO replace with BackingStore class when finishedinterval
- the interval.CacheBuilder
.public CacheBuilder<K,V> clientCacheEntryWeigher(ClientCacheEntryWeigher<K,V> weigher)
ClientCacheEntryWeigher
the ClientCache
will use.weigher
- the ClientCacheEntryWeigher
.CacheBuilder
.public CacheBuilder<K,V> clientCacheSize(int size)
ClientCache
.size
- the size.CacheBuilder
.public CacheBuilder<K,V> clientCache(ClientCache<K,V> clientCache)
Cache
.clientCache
- the client cache implemenation.CacheBuilder
public CacheBuilder<K,V> clientCacheOptions(ClientCacheOptions clientCacheOptions)
ClientCacheOptions
the ClientCache
will use.clientCacheOptions
- the ClientCacheOptions
.CacheBuilder
.public CacheBuilder<K,V> clientCacheCoherencyIntervalMs(long clientCacheCoherencyIntervalMs)
clientCacheCoherencyIntervalMs
- the coherency intervalCacheBuilder
.public CacheBuilder<K,V> raiseServiceEventForReadThrough()
public CacheBuilder<K,V> addRemoteStoreNames(java.util.List<java.lang.String> remoteStoreNames)
remoteStoreNames
- a list of the remote store names.public CacheBuilder<K,V> addRemoteStoreName(java.lang.String remoteStoreName)
remoteStoreName
- the remote store name.public CacheBuilder<K,V> setMaxReadThroughAttempts(int attempts)
ServiceEvents.setLoadObjectHandler(Cache, ValueFactory)
or when using
Cache.readOrAdd(Object, ValueFactory, ReadPolicy)
and Cache.readOrAddAsync(Object, ValueFactory, ReadPolicy)
.attempts
- number of attempts.public CacheBuilder<K,V> setReadThroughRetryInterval(java.time.Duration interval)
ServiceEvents.setLoadObjectHandler(Cache, ValueFactory)
or when using
Cache.readOrAdd(Object, ValueFactory, ReadPolicy)
and Cache.readOrAddAsync(Object, ValueFactory, ReadPolicy)
.interval
- number of attempts.public CacheBuilder<K,V> setMaxRegisterRemoteStoreNameAttempts(int attempts)
Cache.readAndLock(Object)
) is attempted, and no
remote store has been set, the client will automatically attempt to reset the remote store.attempts
- the attempts.public CacheBuilder<K,V> setRegisterRemoteStoreRetryInterval(java.time.Duration interval)
Cache.readAndLock(Object)
) is attempted, and no
remote store has been set, the client will automatically attempt to reset the remote store.interval
- the intervalpublic CacheBuilder<K,V> disableLocalStringKeyCaching()