The Aerospike Knowledge Base has moved to https://support.aerospike.com. Content on https://discuss.aerospike.com is being migrated to either https://support.aerospike.com or https://docs.aerospike.com. Maintenance on articles stored in this repository ceased on December 31st 2022 and this article may be stale. If you have any questions, please do not hesitate to raise a case via https://support.aerospike.com.
#Synopsis
This article explains how policy overwriting works in the C client, using batch timeout as example.
#Details
The C client version has to be 3.0.96 or above for the following examples. Older versions did not support batch timeouts.
1- If null is passed for the batch policy, the user defined global policy timeout is respected. This is the recommended way.
aerospike_batch_get(as, &err, NULL, batch_params, callback, user_data);
2- If a batch policy with standard initialization is passed in, the predefined system timeout is used.
as_policy_batch policy;
as_policy_batch_init(&policy); // AS_POLICY_TIMEOUT_DEFAULT = 1 second
aerospike_batch_get(as, &err, &policy, batch_params, callback, user_data);
3- If a batch policy overriding the standard initialization is passed in, then that timeout will be used.
as_policy_batch policy;
as_policy_batch_init(&policy);
policy.timeout = 50; // 50ms
aerospike_batch_get(as, &err, &policy, batch_params, callback, user_data);
4- Finally, the user defined global policy timeout will be used if directly specified:
as_policy_batch policy;
as_policy_batch_init(&policy);
policy.timeout = as->config.policies.batch.timeout;
aerospike_batch_get(as, &err, &policy, batch_params, callback, user_data);