Class Cache<K,V>
- Type Parameters:
K
- the key type. Must be int, string, byte[], UUID or provide a customKeyEncoder
for theCache
type.V
- the value type.Cache
must be serializable or a customCacheSerializer
/CacheDeserializer
must be provided to theCacheBuilder
.
- All Implemented Interfaces:
com.scaleout.client.caching.ServiceEventHandler<K,
V>
The Cache
class is used to make caching requests to a ScaleOut in-memory data grid.
Cache
's are instantiated with the CacheBuilder
.
Cache
's are logically separated based on the String
name provided to the CacheBuilder
.
-
Method Summary
Modifier and TypeMethodDescriptionabstract CacheResponse<K,
V> Add an object to the ScaleOut cache.abstract CacheResponse<K,
V> add
(K key, V value, CreatePolicy policy) Add an object to the ScaleOut cache with a parameterCreatePolicy
.abstract CacheResponse<K,
V> Add an object to the ScaleOut cache with a parameterCreatePolicy
.abstract CacheResponse<K,
V> Add an object to the ScaleOut cache.abstract CacheResponse<K,
V> addAndLock
(K key, V value) Add an object to the ScaleOut cache with an exclusive lock.abstract CacheResponse<K,
V> addAndLock
(K key, V value, CreatePolicy policy) Add an object to the ScaleOut cache with an exclusive lock and a parameterCreatePolicy
.abstract CompletableFuture<CacheResponse<K,
V>> addAndLockAsync
(K key, V value) Asynchronously add an object to the ScaleOut cache with an exclusive lock.abstract CompletableFuture<CacheResponse<K,
V>> addAndLockAsync
(K key, V value, CreatePolicy policy) Asynchronously add an object to the ScaleOut cache with an exclusive lock and a parameterCreatePolicy
.abstract CompletableFuture<CacheResponse<K,
V>> Asynchronously add an object to the ScaleOut cache.abstract CompletableFuture<CacheResponse<K,
V>> addAsync
(K key, V value, CreatePolicy policy) Asynchronously add an object to the ScaleOut cache with a parameterCreatePolicy
.abstract CacheResponse<K,
V> addOrUpdate
(K key, V value) Add or update an object to/in the ScaleOut cache.abstract CacheResponse<K,
V> addOrUpdate
(K key, V value, CreatePolicy policy) Add or update an object to/in the ScaleOut cache with a customCreatePolicy
.abstract CompletableFuture<CacheResponse<K,
V>> addOrUpdateAsync
(K key, V value) Asynchronously add or update an object to or in the ScaleOut cache.abstract CompletableFuture<CacheResponse<K,
V>> addOrUpdateAsync
(K key, V value, CreatePolicy policy) Asynchronously add or update an object to/in the ScaleOut cache with a customCreatePolicy
.abstract CacheResponse<K,
V> clear()
Clear all objects from the ScaleOut cache.abstract CompletableFuture<CacheResponse<K,
V>> Asynchronously clear all objects from the ScaleOut cache.abstract CreatePolicy
Retrieve the defaultCreatePolicy
used by thisCache
.void
enableAsyncReadThrough
(boolean readThrough) Enable async read through on this service event handler.void
enableAsyncWriteThrough
(boolean writeThrough) Enable async write through on this service event handler.void
enableReadThrough
(boolean readThrough) Enable read through on this service event handler.int
getAppId()
The application ID of this service event handler.Retrieve theGridConnection
associated with this service event handler.TheKeyEncoder
used by this service event handler.abstract CacheResponse<K,
CachedObjectMetadata<K>> getMetadata
(K key) RetrievesCachedObjectMetadata
for an object stored in the cache.abstract CompletableFuture<CacheResponse<K,
CachedObjectMetadata<K>>> getMetadataAsync
(K key) RetrievesCachedObjectMetadata
for an object stored in the cache.abstract CacheResponse<K,
V> Lock an object within the ScaleOut cache for exclusive access.abstract CompletableFuture<CacheResponse<K,
V>> Asynchronously lock an object within the ScaleOut cache for exclusive access.queryObjects
(Filter filter, Class<C> clazz) Query the objects in thisCache
with the parameter filter.abstract CacheResponse<K,
V> Read an object from the ScaleOut cache.abstract CacheResponse<K,
V> read
(K key, ReadPolicy policy) Read a locked object from the ScaleOut cache.abstract CacheResponse<K,
V> readAndLock
(K key) Read an object from the ScaleOut cache and acquire an exclusive lock for that object.abstract CacheResponse<K,
V> readAndLock
(K key, ReadPolicy policy) Read an object from the ScaleOut cache and acquire an exclusive lock for that object using a custom read policy.abstract CompletableFuture<CacheResponse<K,
V>> readAndLockAsync
(K key) Asynchronously read an object from the ScaleOut cache and acquire an exclusive lock for that object.abstract CompletableFuture<CacheResponse<K,
V>> readAndLockAsync
(K key, ReadPolicy policy) Asynchronously read an object from the ScaleOut cache and acquire an exclusive lock for that object using a custom read policy.abstract CompletableFuture<CacheResponse<K,
V>> Asynchronously read an object from the ScaleOut cache.abstract CompletableFuture<CacheResponse<K,
V>> readAsync
(K key, ReadPolicy policy) Asynchronously read a locked object from the ScaleOut cache.abstract CacheResponse<K,
V> readLocked
(K key, LockToken lockToken) Read a locked object from the ScaleOut cache.abstract CacheResponse<K,
V> readLocked
(K key, LockToken lockToken, ReadPolicy policy) Read a locked object from the ScaleOut cache with a custom read policy.abstract CompletableFuture<CacheResponse<K,
V>> readLockedAsync
(K key, LockToken lockToken) Asynchronously read a locked object from the ScaleOut cache.abstract CompletableFuture<CacheResponse<K,
V>> readLockedAsync
(K key, LockToken lockToken, ReadPolicy policy) Asynchronously read a locked object from the ScaleOut cache with a custom read policy.abstract CacheResponse<K,
V> readOrAdd
(K key, ValueFactory<K, V> factory, ReadPolicy policy) Read an object from the ScaleOut cache.abstract CompletableFuture<CacheResponse<K,
V>> readOrAddAsync
(K key, ValueFactory<K, V> factory, ReadPolicy policy) Read an object from the ScaleOut cache.abstract CacheResponse<K,
V> refreshLock
(K key, LockToken lockToken) Refresh a lock on an object within the ScaleOut cache.abstract CompletableFuture<CacheResponse<K,
V>> refreshLockAsync
(K key, LockToken lockToken) Asynchronously refresh a lock on an object within the ScaleOut cache.abstract CacheResponse<K,
V> Remove an object from the ScaleOut cache.abstract CompletableFuture<CacheResponse<K,
V>> removeAsync
(K key) Asynchronously remove an object from the ScaleOut cache.abstract CacheResponse<K,
V> removeLocked
(K key, LockToken lockToken) Remove a locked object from the ScaleOut cache.abstract CompletableFuture<CacheResponse<K,
V>> removeLockedAsync
(K key, LockToken lockToken) Asynchronously remove a locked object from the ScaleOut cache.abstract CacheResponse<K,
V> removeOptimistic
(K key, VersionToken versionToken) Remove an optimistically locked object from the ScaleOut cache.abstract CacheResponse<K,
V> Unlock a locked object within the ScaleOut cache.abstract CompletableFuture<CacheResponse<K,
V>> unlockAsync
(K key, LockToken lockToken) Asynchronously unlock a locked object within the ScaleOut cache.abstract CacheResponse<K,
V> Update an object in the ScaleOut cache.abstract CacheResponse<K,
V> update
(K key, V value, CreatePolicy policy) Update an object in the ScaleOut cache.abstract CacheResponse<K,
V> updateAndRetainLock
(K key, V value, LockToken lockToken) Update a locked object in the ScaleOut cache and retain exclusive access to the object through a lock.abstract CacheResponse<K,
V> updateAndRetainLock
(K key, V value, LockToken lockToken, CreatePolicy policy) Update a locked object in the ScaleOut cache and retain exclusive access to the object through a lock.abstract CompletableFuture<CacheResponse<K,
V>> updateAndRetainLockAsync
(K key, V value, LockToken lockToken) Asynchronously update a locked object in the ScaleOut cache and retain exclusive access to the object through a lock.abstract CompletableFuture<CacheResponse<K,
V>> updateAndRetainLockAsync
(K key, V value, LockToken lockToken, CreatePolicy policy) Asynchronously update a locked object in the ScaleOut cache and retain exclusive access to the object through a lock.abstract CacheResponse<K,
V> updateAndUnlock
(K key, V value, LockToken lockToken) Update a locked object in the ScaleOut cache and unlock the object.abstract CacheResponse<K,
V> updateAndUnlock
(K key, V value, LockToken lockToken, CreatePolicy policy) Update a locked object in the ScaleOut cache and unlock the object.abstract CompletableFuture<CacheResponse<K,
V>> updateAndUnlockAsync
(K key, V value, LockToken lockToken) Asynchronously update a locked object in the ScaleOut cache and unlock the object.abstract CompletableFuture<CacheResponse<K,
V>> updateAndUnlockAsync
(K key, V value, LockToken lockToken, CreatePolicy policy) Asynchronously update a locked object in the ScaleOut cache and release exclusive access to the object.abstract CompletableFuture<CacheResponse<K,
V>> updateAsync
(K key, V value) Asynchronously update an object in the ScaleOut cache.abstract CompletableFuture<CacheResponse<K,
V>> updateAsync
(K key, V value, CreatePolicy policy) Asynchronously update an object in the ScaleOut cache.abstract CacheResponse<K,
V> updateOptimistic
(K key, V value, VersionToken token) Update an object in the ScaleOut cache.abstract CacheResponse<K,
V> updateOptimistic
(K key, V value, VersionToken token, CreatePolicy policy) Update an object in the ScaleOut cache.
-
Method Details
-
add
Add an object to the ScaleOut cache.
The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAdded
.The object must not exist when calling add. If the object may already exists and the client should update the object, use
addOrUpdate(Object, Object)
.If the object already exists, or is added by another client (or thread), the
CacheResponse.getStatus()
will returnRequestStatus.ObjectExists
.The
CreatePolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key or value are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
add
Add an object to the ScaleOut cache.
The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAdded
.The object must not exist when calling add. If the object may already exists and the client should update the object, use
addOrUpdate(Object, Object)
.If the object already exists, or is added by another client (or thread), the
CacheResponse.getStatus()
will returnRequestStatus.ObjectExists
.The
CreatePolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key or value are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.parentKeys
- the parent keys of which this object should be a child.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
addAndLock
Add an object to the ScaleOut cache with an exclusive lock.
The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAddedAndLocked
and theCacheResponse.getLockToken()
will have a value.The object must not exist when calling addExclusive.
If the object already exists, or is added by another client (or thread), the
CacheResponse.getStatus()
will returnRequestStatus.ObjectExists
.The
CreatePolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key or value are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
addOrUpdate
Add or update an object to/in the ScaleOut cache.
The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAdded
and the object is successfully updated whenCacheResponse.getStatus()
returnsRequestStatus.ObjectUpdated
.The
CreatePolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key or value are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
update
Update an object in the ScaleOut cache.
The object is successfully updated when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUpdated
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.Supplying a null value will remove the object from the ScaleOut cache.
The
CreatePolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key is null.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Provide null if the object should be removed.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
updateAndRetainLock
public abstract CacheResponse<K,V> updateAndRetainLock(K key, V value, LockToken lockToken) throws CacheException Update a locked object in the ScaleOut cache and retain exclusive access to the object through a lock.
A lock on an object is acquired through addExclusive, lock, or readAndLock.
The object is successfully updated when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUpdatedAndLockRetained
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.Supplying a null value will remove the object from the ScaleOut cache. Note, the remove attempt will not bypass the lock. This means the lock token must be the appropriate lock in order to successfully remove the object.
The
CreatePolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key is null, the lock token is null, or the lock token has no value.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Provide null if the object should be removed.lockToken
- theLockToken
to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
updateAndUnlock
public abstract CacheResponse<K,V> updateAndUnlock(K key, V value, LockToken lockToken) throws CacheException Update a locked object in the ScaleOut cache and unlock the object.
A lock on an object is acquired through addExclusive, lock, or readAndLock.
The object is successfully updated when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUpdatedAndUnlocked
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.Supplying a null value will remove the object from the ScaleOut cache. Note, the remove attempt will not bypass the lock. This means the lock token must be the appropriate lock in order to successfully remove the object.
The
CreatePolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key is null, the lock token is null, or the lock token has no value.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Provide null if the object should be removed.lockToken
- theLockToken
to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
add
Add an object to the ScaleOut cache with a parameter
CreatePolicy
.Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAdded
.The object must not exist when calling add. If the object may already exists and the client should update the object, use
addOrUpdate(Object, Object)
.If the object already exists, or is added by another client (or thread), the
CacheResponse.getStatus()
will returnRequestStatus.ObjectExists
.IllegalArgumentException
is thrown if the key or value are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.policy
- the policy to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
add
public abstract CacheResponse<K,V> add(K key, V value, CreatePolicy policy, List<K> parentKeys) throws CacheException Add an object to the ScaleOut cache with a parameter
CreatePolicy
.Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAdded
.The object must not exist when calling add. If the object may already exists and the client should update the object, use
addOrUpdate(Object, Object)
.If the object already exists, or is added by another client (or thread), the
CacheResponse.getStatus()
will returnRequestStatus.ObjectExists
.IllegalArgumentException
is thrown if the key or value are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.policy
- the policy to use.parentKeys
- the parent keys to which this object should be a dependant.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
addAndLock
public abstract CacheResponse<K,V> addAndLock(K key, V value, CreatePolicy policy) throws CacheException Add an object to the ScaleOut cache with an exclusive lock and a parameter
CreatePolicy
.Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAddedAndLocked
and theCacheResponse.getLockToken()
will have a value.The object must not exist when calling addExclusive.
If the object already exists, or is added by another client (or thread), the
CacheResponse.getStatus()
will returnRequestStatus.ObjectExists
.IllegalArgumentException
is thrown if the key, value, or create policy are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.policy
- the policy to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
addOrUpdate
public abstract CacheResponse<K,V> addOrUpdate(K key, V value, CreatePolicy policy) throws CacheException Add or update an object to/in the ScaleOut cache with a custom
CreatePolicy
.Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAdded
and the object is successfully updated whenCacheResponse.getStatus()
returnsRequestStatus.ObjectUpdated
.IllegalArgumentException
is thrown if the key or value are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.policy
- the policy to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
update
public abstract CacheResponse<K,V> update(K key, V value, CreatePolicy policy) throws CacheException Update an object in the ScaleOut cache.
Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.The object is successfully updated when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUpdated
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.Supplying a null value will remove the object from the ScaleOut cache.
IllegalArgumentException
is thrown if the key or create policy are null.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Provide null if the object should be removed.policy
- the policy to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
updateOptimistic
public abstract CacheResponse<K,V> updateOptimistic(K key, V value, VersionToken token) throws CacheException Update an object in the ScaleOut cache.
If the version token supplied matches the version of the object stored in the cache then the object will be updated. Otherwise the operation will return
RequestStatus.ObjectVersionMismatch
.The object is successfully updated when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUpdated
.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Provide null if the object should be removed.token
- theVersionToken
to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
updateOptimistic
public abstract CacheResponse<K,V> updateOptimistic(K key, V value, VersionToken token, CreatePolicy policy) throws CacheException Update an object in the ScaleOut cache.
If the version token supplied matches the version of the object stored in the cache then the object will be updated. Otherwise the operation will return
RequestStatus.ObjectVersionMismatch
.Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Provide null if the object should be removed.token
- theVersionToken
to use.policy
- the policy to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
updateAndRetainLock
public abstract CacheResponse<K,V> updateAndRetainLock(K key, V value, LockToken lockToken, CreatePolicy policy) throws CacheException Update a locked object in the ScaleOut cache and retain exclusive access to the object through a lock.
Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.A lock on an object is acquired through addExclusive, lock, or readAndLock.
The object is successfully updated when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUpdatedAndLockRetained
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.Supplying a null value will remove the object from the ScaleOut cache. Note, the remove attempt will not bypass the lock. This means the lock token must be the appropriate lock in order to successfully remove the object.
IllegalArgumentException
is thrown if the key is null, the lock token is null, the lock token has no value, or the create policy is null.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Provide null if the object should be removed.lockToken
- theLockToken
to use.policy
- the policy to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
updateAndUnlock
public abstract CacheResponse<K,V> updateAndUnlock(K key, V value, LockToken lockToken, CreatePolicy policy) throws CacheException Update a locked object in the ScaleOut cache and unlock the object.
Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.A lock on an object is acquired through addExclusive, lock, or readAndLock.
The object is successfully updated when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUpdatedAndUnlocked
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.Supplying a null value will remove the object from the ScaleOut cache. Note, the remove attempt will not bypass the lock. This means the lock token must be the appropriate lock in order to successfully remove the object.
IllegalArgumentException
is thrown if the key is null, the lock token is null, the lock token has no value, or the create policy is null.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Null if the object should be removed.lockToken
- theLockToken
to use.policy
- the policy to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
read
Read an object from the ScaleOut cache.
The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrieved
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.The
ReadPolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key is null.- Parameters:
key
- the unique identifier for this object.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
readAndLock
Read an object from the ScaleOut cache and acquire an exclusive lock for that object.
The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrievedAndLocked
.The
LockToken
is retrieved from theCacheResponse.getLockToken()
The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.The object was locked by another client/thread in the ScaleOut cache if
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.The
ReadPolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key is null.- Parameters:
key
- the unique identifier for this object.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
readLocked
Read a locked object from the ScaleOut cache.
The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrievedAndLocked
.A lock on an object is acquired through addExclusive, lock, or readAndLock.
The refreshed
LockToken
is retrieved from theCacheResponse.getLockToken()
The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.The object was locked by another client/thread in the ScaleOut cache if
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.The
ReadPolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key is null, the lock token is null, or the lock token has no value.- Parameters:
key
- the unique identifier for this object.lockToken
- theLockToken
to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
read
Read a locked object from the ScaleOut cache.
Specify a custom
ReadPolicy
to adjust read properties.The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrievedAndLocked
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.IllegalArgumentException
is thrown if the key is null orReadPolicy
is null.- Parameters:
key
- the unique identifier for this object.policy
- theReadPolicy
to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
readAndLock
Read an object from the ScaleOut cache and acquire an exclusive lock for that object using a custom read policy.
Specify a custom
ReadPolicy
to adjust read properties.The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrievedAndLocked
.The
LockToken
is retrieved from theCacheResponse.getLockToken()
The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.The object was locked by another client/thread in the ScaleOut cache if
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.IllegalArgumentException
is thrown if the key is null orReadPolicy
is null.- Parameters:
key
- the unique identifier for this object.policy
- theReadPolicy
to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
readOrAdd
public abstract CacheResponse<K,V> readOrAdd(K key, ValueFactory<K, V> factory, ReadPolicy policy) throws CacheExceptionRead an object from the ScaleOut cache. If the object is not present, the parameter
ValueFactory
will be called and the value will be added. Once the value has been added, the newly added value will be returned.Specify a custom
ReadPolicy
to adjust read properties.The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrieved
.IllegalArgumentException
is thrown if the key, value factory, or read policy, are null.- Parameters:
key
- the unique identifier for this object.factory
- theValueFactory
to use.policy
- theReadPolicy
to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
readLocked
public abstract CacheResponse<K,V> readLocked(K key, LockToken lockToken, ReadPolicy policy) throws CacheException Read a locked object from the ScaleOut cache with a custom read policy.
Specify a custom
ReadPolicy
to adjust read properties.The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrievedAndLocked
.A lock on an object is acquired through addExclusive, lock, or readAndLock.
sThe refreshed
LockToken
is retrieved from theCacheResponse.getLockToken()
The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.The object was locked by another client/thread in the ScaleOut cache if
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.IllegalArgumentException
is thrown if the key is null, the lock token is null, the lock token has no value, or theReadPolicy
is null.- Parameters:
key
- the unique identifier for this object.lockToken
- theLockToken
to use.policy
- theReadPolicy
to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
remove
Remove an object from the ScaleOut cache.
The object is successfully removed when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRemoved
.IllegalArgumentException
is thrown if the key is null.- Parameters:
key
- the unique identifier for this object.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
removeLocked
Remove a locked object from the ScaleOut cache.
The object is successfully removed when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRemoved
.A lock on an object is acquired through addExclusive, lock, or readAndLock.
The object was locked by another client/thread in the ScaleOut cache if
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.IllegalArgumentException
is thrown if the key is null, the lock token is null, or the lock token has no value.- Parameters:
key
- the unique identifier for this object.lockToken
- theLockToken
to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
removeOptimistic
public abstract CacheResponse<K,V> removeOptimistic(K key, VersionToken versionToken) throws CacheException Remove an optimistically locked object from the ScaleOut cache.
The object is successfully removed when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRemoved
.- Parameters:
key
- the unique identifier for this object.versionToken
- theVersionToken
to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
lock
Lock an object within the ScaleOut cache for exclusive access.
The
LockToken
is retrieved from theCacheResponse.getLockToken()
The object is successfully locked when
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.IllegalArgumentException
is thrown if the key is null- Parameters:
key
- the unique identifier for this object.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
refreshLock
Refresh a lock on an object within the ScaleOut cache.
The
LockToken
is retrieved from theCacheResponse.getLockToken()
The lock is successfully refreshed when
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.A lock on an object is acquired through addExclusive, lock, or readAndLock.
IllegalArgumentException
is thrown if the key is null, the lock token is null, or the lock token has no value.- Parameters:
key
- the unique identifier for this object.lockToken
- theLockToken
to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
unlock
Unlock a locked object within the ScaleOut cache.
A lock on an object is acquired through addExclusive, lock, or readAndLock.
The object is successfully unlocked when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUnlocked
.IllegalArgumentException
is thrown if the key is null, the lock token is null, or the lock token has no value.- Parameters:
key
- the unique identifier for this object.lockToken
- theLockToken
to use.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
clear
Clear all objects from the ScaleOut cache.
The cache is successfully cleared when
CacheResponse.getStatus()
returnsRequestStatus.CacheCleared
.- Returns:
- a
CacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
queryObjects
public abstract <C extends V> Iterable<V> queryObjects(Filter filter, Class<C> clazz) throws CacheException Query the objects in this
Cache
with the parameter filter.Filters are constructed using the
FilterFactory
- Type Parameters:
C
- the value type.- Parameters:
filter
- the filter.clazz
- the class type.- Returns:
- an iterable of 0 to many objects of type
Cache
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
queryKeys
public abstract <C extends V> Iterable<K> queryKeys(Filter filter, Class<C> clazz) throws CacheException Query the objects in this
Cache
with the parameter filter returning an iterable ofCache
keys.Filters are constructed using the
FilterFactory
- Type Parameters:
C
- the value type.- Parameters:
filter
- the filter.clazz
- the class type.- Returns:
- an iterable of 0 to many keys of type
Cache
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
getMetadata
Retrieves
CachedObjectMetadata
for an object stored in the cache.Returns
RequestStatus.ObjectRetrieved
if the object exists.Returns
RequestStatus.ObjectNotFound
if the object does not exist.- Parameters:
key
- the key to get metadata for.- Returns:
- the metadata for the cache object.
- Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
addAsync
public abstract CompletableFuture<CacheResponse<K,V>> addAsync(K key, V value) throws CacheException Asynchronously add an object to the ScaleOut cache.
The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAdded
.The object must not exist when calling add. If the object may already exists and the client should update the object, use
addOrUpdate(Object, Object)
.If the object already exists, or is added by another client (or thread), the
CacheResponse.getStatus()
will returnRequestStatus.ObjectExists
.The
CreatePolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key or value are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
addAndLockAsync
public abstract CompletableFuture<CacheResponse<K,V>> addAndLockAsync(K key, V value) throws CacheException Asynchronously add an object to the ScaleOut cache with an exclusive lock.
The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAddedAndLocked
and theCacheResponse.getLockToken()
will have a value.The object must not exist when calling addExclusive.
If the object already exists, or is added by another client (or thread), the
CacheResponse.getStatus()
will returnRequestStatus.ObjectExists
.The
CreatePolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key or value are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
addOrUpdateAsync
public abstract CompletableFuture<CacheResponse<K,V>> addOrUpdateAsync(K key, V value) throws CacheException Asynchronously add or update an object to or in the ScaleOut cache.
The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAdded
and the object is successfully updated whenCacheResponse.getStatus()
returnsRequestStatus.ObjectUpdated
.The
CreatePolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key or value are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
updateAsync
public abstract CompletableFuture<CacheResponse<K,V>> updateAsync(K key, V value) throws CacheException Asynchronously update an object in the ScaleOut cache.
The object is successfully updated when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUpdated
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.Supplying a null value will remove the object from the ScaleOut cache.
The
CreatePolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key is null.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Provide null if the object should be removed.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
updateAndRetainLockAsync
public abstract CompletableFuture<CacheResponse<K,V>> updateAndRetainLockAsync(K key, V value, LockToken lockToken) throws CacheException Asynchronously update a locked object in the ScaleOut cache and retain exclusive access to the object through a lock.
A lock on an object is acquired through addExclusive, lock, or readAndLock.
The object is successfully updated when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUpdatedAndLockRetained
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.Supplying a null value will remove the object from the ScaleOut cache. Note, the remove attempt will not bypass the lock. This means the lock token must be the appropriate lock in order to successfully remove the object.
The
CreatePolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key is null, the lock token is null, or the lock token has no value.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Provide null if the object should be removed.lockToken
- theLockToken
to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
updateAndUnlockAsync
public abstract CompletableFuture<CacheResponse<K,V>> updateAndUnlockAsync(K key, V value, LockToken lockToken) throws CacheException Asynchronously update a locked object in the ScaleOut cache and unlock the object.
A lock on an object is acquired through addExclusive, lock, or readAndLock.
The object is successfully updated when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUpdatedAndUnlocked
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.Supplying a null value will remove the object from the ScaleOut cache. Note, the remove attempt will not bypass the lock. This means the lock token must be the appropriate lock in order to successfully remove the object.
The
CreatePolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key is null, the lock token is null, or the lock token has no value.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Provide null if the object should be removed.lockToken
- theLockToken
to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
addAsync
public abstract CompletableFuture<CacheResponse<K,V>> addAsync(K key, V value, CreatePolicy policy) throws CacheException Asynchronously add an object to the ScaleOut cache with a parameter
CreatePolicy
.Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAdded
.The object must not exist when calling add. If the object may already exists and the client should update the object, use
addOrUpdate(Object, Object)
.If the object already exists, or is added by another client (or thread), the
CacheResponse.getStatus()
will returnRequestStatus.ObjectExists
.IllegalArgumentException
is thrown if the key or value are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.policy
- the policy to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
addAndLockAsync
public abstract CompletableFuture<CacheResponse<K,V>> addAndLockAsync(K key, V value, CreatePolicy policy) throws CacheException Asynchronously add an object to the ScaleOut cache with an exclusive lock and a parameter
CreatePolicy
.Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAddedAndLocked
and theCacheResponse.getLockToken()
will have a value.The object must not exist when calling addExclusive.
If the object already exists, or is added by another client (or thread), the
CacheResponse.getStatus()
will returnRequestStatus.ObjectExists
.IllegalArgumentException
is thrown if the key, value, or create policy are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.policy
- the policy to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
addOrUpdateAsync
public abstract CompletableFuture<CacheResponse<K,V>> addOrUpdateAsync(K key, V value, CreatePolicy policy) throws CacheException Asynchronously add or update an object to/in the ScaleOut cache with a custom
CreatePolicy
.Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.The object is successfully added when
CacheResponse.getStatus()
returnsRequestStatus.ObjectAdded
and the object is successfully updated whenCacheResponse.getStatus()
returnsRequestStatus.ObjectUpdated
.IllegalArgumentException
is thrown if the key or value are null.- Parameters:
key
- the unique identifier for this object.value
- the object to add to the ScaleOut cache.policy
- the policy to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
updateAsync
public abstract CompletableFuture<CacheResponse<K,V>> updateAsync(K key, V value, CreatePolicy policy) throws CacheException Asynchronously update an object in the ScaleOut cache.
Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.The object is successfully updated when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUpdated
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.Supplying a null value will remove the object from the ScaleOut cache.
IllegalArgumentException
is thrown if the key or create policy are null.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Provide null if the object should be removed.policy
- the policy to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
updateAndRetainLockAsync
public abstract CompletableFuture<CacheResponse<K,V>> updateAndRetainLockAsync(K key, V value, LockToken lockToken, CreatePolicy policy) throws CacheException Asynchronously update a locked object in the ScaleOut cache and retain exclusive access to the object through a lock.
Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.A lock on an object is acquired through addExclusive, lock, or readAndLock.
The object is successfully updated when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUpdatedAndLockRetained
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.Supplying a null value will remove the object from the ScaleOut cache. Note, the remove attempt will not bypass the lock. This means the lock token must be the appropriate lock in order to successfully remove the object.
IllegalArgumentException
is thrown if the key is null, the lock token is null, the lock token has no value, or the create policy is null.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Provide null if the object should be removed.lockToken
- theLockToken
to use.policy
- the policy to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
updateAndUnlockAsync
public abstract CompletableFuture<CacheResponse<K,V>> updateAndUnlockAsync(K key, V value, LockToken lockToken, CreatePolicy policy) throws CacheException Asynchronously update a locked object in the ScaleOut cache and release exclusive access to the object.
Specify a custom
CreatePolicy
to adjust object metadata such asTimeoutType
,GeoServerReadMode
, and other properties.A lock on an object is acquired through addExclusive, lock, or readAndLock.
The object is successfully updated when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUpdatedAndUnlocked
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.Supplying a null value will remove the object from the ScaleOut cache. Note, the remove attempt will not bypass the lock. This means the lock token must be the appropriate lock in order to successfully remove the object.
IllegalArgumentException
is thrown if the key is null, the lock token is null, the lock token has no value, or the create policy is null.- Parameters:
key
- the unique identifier for this object.value
- the object to update in the ScaleOut cache. Null if the object should be removed.lockToken
- theLockToken
to use.policy
- the policy to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
readAsync
Asynchronously read an object from the ScaleOut cache.
The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrieved
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.The
ReadPolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key is null.- Parameters:
key
- the unique identifier for this object.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
readAndLockAsync
Asynchronously read an object from the ScaleOut cache and acquire an exclusive lock for that object.
The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrievedAndLocked
.The
LockToken
is retrieved from theCacheResponse.getLockToken()
The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.The object was locked by another client/thread in the ScaleOut cache if
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.The
ReadPolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key is null.- Parameters:
key
- the unique identifier for this object.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
readLockedAsync
public abstract CompletableFuture<CacheResponse<K,V>> readLockedAsync(K key, LockToken lockToken) throws CacheException Asynchronously read a locked object from the ScaleOut cache.
The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrievedAndLocked
.A lock on an object is acquired through addExclusive, lock, or readAndLock.
The refreshed
LockToken
is retrieved from theCacheResponse.getLockToken()
The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.The object was locked by another client/thread in the ScaleOut cache if
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.The
ReadPolicy
as defined by theCacheBuilder
will be used.IllegalArgumentException
is thrown if the key is null, the lock token is null, or the lock token has no value.- Parameters:
key
- the unique identifier for this object.lockToken
- theLockToken
to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
readAsync
public abstract CompletableFuture<CacheResponse<K,V>> readAsync(K key, ReadPolicy policy) throws CacheException Asynchronously read a locked object from the ScaleOut cache.
Specify a custom
ReadPolicy
to adjust read properties.The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrievedAndLocked
.The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.IllegalArgumentException
is thrown if the key is null orReadPolicy
is null.- Parameters:
key
- the unique identifier for this object.policy
- theReadPolicy
to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
readAndLockAsync
public abstract CompletableFuture<CacheResponse<K,V>> readAndLockAsync(K key, ReadPolicy policy) throws CacheException Asynchronously read an object from the ScaleOut cache and acquire an exclusive lock for that object using a custom read policy.
Specify a custom
ReadPolicy
to adjust read properties.The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrievedAndLocked
.The
LockToken
is retrieved from theCacheResponse.getLockToken()
The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.The object was locked by another client/thread in the ScaleOut cache if
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.IllegalArgumentException
is thrown if the key is null orReadPolicy
is null.- Parameters:
key
- the unique identifier for this object.policy
- theReadPolicy
to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
readOrAddAsync
public abstract CompletableFuture<CacheResponse<K,V>> readOrAddAsync(K key, ValueFactory<K, V> factory, ReadPolicy policy) throws CacheExceptionRead an object from the ScaleOut cache. If the object is not present, the parameter
ValueFactory
will be called and the value will be added. Once the value has been added, the newly added value will be returned.Specify a custom
ReadPolicy
to adjust read properties.The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrieved
.IllegalArgumentException
is thrown if the key, value factory, or read policy, are null.- Parameters:
key
- the unique identifier for this object.factory
- theValueFactory
to use.policy
- theReadPolicy
to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
readLockedAsync
public abstract CompletableFuture<CacheResponse<K,V>> readLockedAsync(K key, LockToken lockToken, ReadPolicy policy) throws CacheException Asynchronously read a locked object from the ScaleOut cache with a custom read policy.
Specify a custom
ReadPolicy
to adjust read properties.The object is successfully retrieved when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRetrievedAndLocked
.A lock on an object is acquired through addExclusive, lock, or readAndLock.
The refreshed
LockToken
is retrieved from theCacheResponse.getLockToken()
The object must exist in the ScaleOut cache. If the object does not exist,
CacheResponse.getStatus()
returnsRequestStatus.ObjectNotFound
.The object was locked by another client/thread in the ScaleOut cache if
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.IllegalArgumentException
is thrown if the key is null, the lock token is null, the lock token has no value, or theReadPolicy
is null.- Parameters:
key
- the unique identifier for this object.lockToken
- theLockToken
to use.policy
- theReadPolicy
to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
removeAsync
Asynchronously remove an object from the ScaleOut cache.
The object is successfully removed when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRemoved
.IllegalArgumentException
is thrown if the key is null.- Parameters:
key
- the unique identifier for this object.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
removeLockedAsync
public abstract CompletableFuture<CacheResponse<K,V>> removeLockedAsync(K key, LockToken lockToken) throws CacheException Asynchronously remove a locked object from the ScaleOut cache.
The object is successfully removed when
CacheResponse.getStatus()
returnsRequestStatus.ObjectRemoved
.A lock on an object is acquired through addExclusive, lock, or readAndLock.
The object was locked by another client/thread in the ScaleOut cache if
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.IllegalArgumentException
is thrown if the key is null, the lock token is null, or the lock token has no value.- Parameters:
key
- the unique identifier for this object.lockToken
- theLockToken
to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
lockAsync
Asynchronously lock an object within the ScaleOut cache for exclusive access.
The
LockToken
is retrieved from theCacheResponse.getLockToken()
The object is successfully locked when
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.IllegalArgumentException
is thrown if the key is null- Parameters:
key
- the unique identifier for this object.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
refreshLockAsync
public abstract CompletableFuture<CacheResponse<K,V>> refreshLockAsync(K key, LockToken lockToken) throws CacheException Asynchronously refresh a lock on an object within the ScaleOut cache.
The
LockToken
is retrieved from theCacheResponse.getLockToken()
The lock is successfully refreshed when
CacheResponse.getStatus()
returnsRequestStatus.ObjectLocked
.A lock on an object is acquired through addExclusive, lock, or readAndLock.
IllegalArgumentException
is thrown if the key is null, the lock token is null, or the lock token has no value.- Parameters:
key
- the unique identifier for this object.lockToken
- theLockToken
to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
unlockAsync
public abstract CompletableFuture<CacheResponse<K,V>> unlockAsync(K key, LockToken lockToken) throws CacheException Asynchronously unlock a locked object within the ScaleOut cache.
A lock on an object is acquired through addExclusive, lock, or readAndLock.
The object is successfully unlocked when
CacheResponse.getStatus()
returnsRequestStatus.ObjectUnlocked
.IllegalArgumentException
is thrown if the key is null, the lock token is null, or the lock token has no value.- Parameters:
key
- the unique identifier for this object.lockToken
- theLockToken
to use.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
clearAsync
Asynchronously clear all objects from the ScaleOut cache.
The cache is successfully cleared when
CacheResponse.getStatus()
returnsRequestStatus.CacheCleared
.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
getMetadataAsync
public abstract CompletableFuture<CacheResponse<K,CachedObjectMetadata<K>>> getMetadataAsync(K key) throws CacheException Retrieves
CachedObjectMetadata
for an object stored in the cache.Returns
RequestStatus.ObjectRetrieved
if the object exists.Returns
RequestStatus.ObjectNotFound
if the object does not exist.- Parameters:
key
- the key to get metadata for.- Returns:
- a
CompletableFuture
that returns aCacheResponse
. - Throws:
CacheException
- The cache will automatically retry the request if no ScaleOut gateways are available. If all retries are exhausted, aCacheException
will be thrown.
-
createPolicy
Retrieve the defaultCreatePolicy
used by thisCache
.- Returns:
- the
CreatePolicy
used by thisCache
.
-
getAppId
int getAppId()The application ID of this service event handler.- Returns:
- the application id.
-
getKeyEncoder
KeyEncoder<K> getKeyEncoder()TheKeyEncoder
used by this service event handler.- Returns:
- the
KeyEncoder
-
enableAsyncWriteThrough
void enableAsyncWriteThrough(boolean writeThrough) Enable async write through on this service event handler.- Parameters:
writeThrough
- true/false to enable/disable async write through on this service event handler.
-
enableAsyncReadThrough
void enableAsyncReadThrough(boolean readThrough) Enable async read through on this service event handler.- Parameters:
readThrough
- true/false to enable/disable async write through on this service event handler.
-
enableReadThrough
void enableReadThrough(boolean readThrough) Enable read through on this service event handler.- Parameters:
readThrough
- true/false to enable disable read through on this service event handler.
-
getGridConnection
GridConnection getGridConnection()Retrieve theGridConnection
associated with this service event handler.- Returns:
- the
GridConnection
.
-