Policy Overwriting on C Client


#1

#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);