Search code examples
aerospike

Aerospike operations on list/map


Does aerospike go client support operations such as add/remove to list/map in a bin directly from the client i.e, without doing get and then put operation?

aql> select * from test_ns.test_set where PK='12345678'
+----------------------------+---------------------------+
| map_bin                    | list_bin                  |
+----------------------------+---------------------------+
| MAP('{22370:1, 23471:1}')  | LIST('[22370, 1234543]')  |
+----------------------------+---------------------------+

In the above example, I want to add an entry to the list in list bin or add an entry in the map,

I know we can use UDF's for that but Can I do it directly from aerospike client without writing UDF as UDF operations are costly?

P.S. I am using aerospike Go client


Solution

  • The Go client for Aerospike, like all other clients, supports list and map API operations such as list-append (ListAppendOp). In most clients there are wrapper methods for it, but you can always use the operate() method to execute multiple operations on a single record, including atomic list and map operations.