Skip to main content

Record Operations

Aerospike provides simple interfaces for reading data from and writing data to an Aerospike cluster. They cover the standard CRUD (create, read, update, delete) use-cases.

Every Aerospike client can perform the following full-record operations, no matter which language it's written in:

putWrite a record. Performs the equivalent of create, update or replace, depending on the write policy given to the put operation.
deleteRemove a record from the database. Generates a tombstone when using the durable-delete policy.
getRead the record. Specific bins can be selected.
addAdd (or subtract) a value in an integer bin. Used to implement counters. Also called increment.
Modify a string or byte array bin.
touchIncrement the generation counter.
operateApply multiple bin operations as an atomic transaction.

Best practice is to apply add and append/prepend operations as part of a transaction, and not to use the full-record operation variant described above.

Filtering Operations

An operation can be conditionally applied, based on the result of a filter expression. If the filter expression evaluates to true, the operation will execute. Older versions starting with Aerospike 4.7 can apply a predicate filter to the operation.

Support for predicate filters is removed in Aerospike 6.0, so we recommend that filter expressions added in version 5.2 be used in their place.

Code examples of record operations

The following examples use Python to perform create, read, update, and delete (CRUD) operations on a record. The syntax differs per Aerospike client, based on the needs of the operating system. These examples model common usage:

Create a record

key = (namespace_name, set_name, user_key)
bins = {
'l': [ "qwertyuiop", 1, bytearray("asd;as[d'as;d", "utf-8") ],
'm': { "key": "asd';q;'1';" },
'i': 1234,
'f': 3.14159265359,
's': '!@#@#$QSDAsd;as'

client.put(key, bins)


  • key: The primary key of the record to create.
  • bins: Bin name and value pairs to insert into the bins upon creation.

Read a record



  • key: The primary key of the record to read.

Update a record

update_bins = {
'b'=: u"\ud83d\ude04"
'i': aerospike.null()

client.put(key, update_bins)


  • key: The primary key of the record to update.
  • update_bins: Bin name and value pairs to upsert into the bins.

Adds a blob bin. Removes the integer bin by overwriting with null.

Delete a record



  • key: The primary key of the record to delete.

Usage note for all examples

All full-record read and write operations accept policy parameters: Max Retries and Total Timeout.

Write operations take an optional time-to-live (TTL) parameter that specifies how long to protect a record from automatic eviction by the system. Set the TTL to -1 to tell Aerospike to never evict that data.


See these topics for language-specific examples: