Aerospike provides a key based API to access and modify data into the cluster.
The Key API is a collection of APIs that use as_key as for looking up records for accessing and modifying in the cluster.
|
as_status | aerospike_key_apply (aerospike *as, as_error *err, const as_policy_apply *policy, const as_key *key, const char *module, const char *function, as_list *arglist, as_val **result) |
|
as_status | aerospike_key_exists (aerospike *as, as_error *err, const as_policy_read *policy, const as_key *key, as_record **rec) |
|
as_status | aerospike_key_get (aerospike *as, as_error *err, const as_policy_read *policy, const as_key *key, as_record **rec) |
|
as_status | aerospike_key_operate (aerospike *as, as_error *err, const as_policy_operate *policy, const as_key *key, const as_operations *ops, as_record **rec) |
|
as_status | aerospike_key_put (aerospike *as, as_error *err, const as_policy_write *policy, const as_key *key, as_record *rec) |
|
as_status | aerospike_key_remove (aerospike *as, as_error *err, const as_policy_remove *policy, const as_key *key) |
|
as_status | aerospike_key_select (aerospike *as, as_error *err, const as_policy_read *policy, const as_key *key, const char *bins[], as_record **rec) |
|
Lookup a record by key, then apply the UDF.
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
else {
}
- Parameters
-
as | The aerospike instance to use for this operation. |
err | The as_error to be populated if an error occurs. |
policy | The policy to use for this operation. If NULL, then the default policy will be used. |
key | The key of the record. |
module | The module containing the function to execute. |
function | The function to execute. |
arglist | The arguments for the function. |
result | The return value from the function. |
- Returns
- AEROSPIKE_OK if successful. Otherwise an error.
Check if a record exists in the cluster via its key. The record's metadata will be populated if the record exists.
bool exists = true;
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
else {
fprintf(stdout, "Record %s", exists ? "exists." : "doesn't exist.");
}
- Parameters
-
as | The aerospike instance to use for this operation. |
err | The as_error to be populated if an error occurs. |
policy | The policy to use for this operation. If NULL, then the default policy will be used. |
key | The key of the record. |
rec | The metadata will be populated if the record exists. |
- Returns
- AEROSPIKE_OK if successful. AEROSPIKE_ERR_RECORD_NOT_FOUND if not found. Otherwise an error.
Look up a record by key, then return all bins.
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
else {
}
- Parameters
-
as | The aerospike instance to use for this operation. |
err | The as_error to be populated if an error occurs. |
policy | The policy to use for this operation. If NULL, then the default policy will be used. |
key | The key of the record. |
rec | The record to be populated with the data from request. |
- Returns
- AEROSPIKE_OK if successful. Otherwise an error.
Lookup a record by key, then perform specified operations.
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
else {
}
- Parameters
-
as | The aerospike instance to use for this operation. |
err | The as_error to be populated if an error occurs. |
policy | The policy to use for this operation. If NULL, then the default policy will be used. |
key | The key of the record. |
ops | The operations to perform on the record. |
rec | The record to be populated with the data from AS_OPERATOR_READ operations. |
- Returns
- AEROSPIKE_OK if successful. Otherwise an error.
Store a record in the cluster.
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
- Parameters
-
as | The aerospike instance to use for this operation. |
err | The as_error to be populated if an error occurs. |
policy | The policy to use for this operation. If NULL, then the default policy will be used. |
key | The key of the record. |
rec | The record containing the data to be written. |
- Returns
- AEROSPIKE_OK if successful. Otherwise an error.
Remove a record from the cluster.
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
- Parameters
-
as | The aerospike instance to use for this operation. |
err | The as_error to be populated if an error occurs. |
policy | The policy to use for this operation. If NULL, then the default policy will be used. |
key | The key of the record. |
- Returns
- AEROSPIKE_OK if successful and AEROSPIKE_ERR_RECORD_NOT_FOUND if the record was not found. Otherwise an error.
Lookup a record by key, then return specified bins.
char * select[] = {"bin1", "bin2", "bin3", NULL};
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
else {
}
- Parameters
-
as | The aerospike instance to use for this operation. |
err | The as_error to be populated if an error occurs. |
policy | The policy to use for this operation. If NULL, then the default policy will be used. |
key | The key of the record. |
bins | The bins to select. A NULL terminated array of NULL terminated strings. |
rec | The record to be populated with the data from request. |
- Returns
- AEROSPIKE_OK if successful. Otherwise an error.