16.2.3 Notes about manipulating data
- Organization of this subsection
(1) Notes about manipulating data
The following notes apply to manipulating data:
-
If a specified key is already in cache, put() unconditionally updates the value. If you do not want to update values unconditionally, use the following methods:
-
create()
Only when a new key is stored, this method associates a value with the key and stores the value.
-
update()
Only when a specified key is already stored, this method associates a value with the key and stores the value.
-
replace()
Compares the value associated with a specified key with the value (comparativeValue) specified as the condition. Then, only if their values match, this method associates the value with the key and stores the value.
-
-
If a key specified during the execution of get() does not exist in the cache, null is returned.
-
If a key specified during the execution of replace() does not exist, CacheException.EAD_ERROR_SERVER_REPLACE_METHOD_KEY_NOT_EXIST is returned.
-
If comparison results do not match during the execution of replace(), CacheException.EAD_ERROR_SERVER_REPLACE_METHOD_NOT_MATCHED is returned.
-
If a key specified during the execution of create() already exists, CacheException.EAD_ERROR_SERVER_CREATE_METHOD_KEY_EXIST is returned.
-
If a key specified during the execution of update() does not exist, CacheException.EAD_ERROR_SERVER_UPDATE_METHOD_KEY_NOT_EXIST is returned.
(2) Notes about batch data operations
The following notes apply to batch data operations.
-
If a specified key has already been stored in the cache, putAll()updates the value unconditionally.
-
Because caches are not locked while operations are ongoing, a target value might be changed by another cache operation during a batch operation.
-
When batch operations are performed on a large amount of data, a large amount of memory might be required by EADS clients and EADS servers.
-
When batch operations are performed on a large amount of data, it might take a long time to complete the processing. To ensure proper operation, make sure that you design a timeout value that is appropriate for the processing time.
-
If manipulation of a key fails or the cluster configuration is changed while batch operation with multiple keys specified is underway, the batch operation will be terminated and any operations that have not yet been performed will be cancelled. Similarly, when the cluster configuration is changed by a user operation, such as scale-out processing (adding EADS servers) or restoration processing, during batch operation, any operations that have not yet been performed will be cancelled.
Identify the key resulting in an error and determine the cause of the error from each API method's return value. You can identify a key whose manipulation was cancelled based on the error code of CacheException.EAD_ERROR_CLIENT_BATCH_CANCEL.
-
When all key manipulations fail when batch operation with multiple keys specified is attempted, CacheException.EAD_ERROR_BATCH_FAILED_ALL is returned.
-
When only some key manipulations fail when batch operation with multiple keys specified is performed, CacheException.EAD_ERROR_BATCH_FAILED_PART is returned.