Designing map behavior using set in aerospike


Hi, I have an object which has map inside it.

e.g Person - > Map (city_visited,counter_for_number_of_times_city_visited). I am trying to design this use case in aerospike so that i can do CRUD in single transactions. Below are the things that i tried.

  1. Storing map directly as a bin - But issue in this case is I have to take out map and iterate over the map to get the counter and in mean time someone can update the set.
  2. Storing city_visited as different bins - But in this case we have many bins and it grows as the city_visited increases and there is no way to maintain the counter.
  3. Take 2 set one for person and other for counter like below:

Persons (bin) - personId (PK), personName, person_description. Counter (bin) - personId|city_visited (PK), counter, personId(Secondary Index).

Here it would be possible to query counter and also counter statistics.

Just wanted an opinion is there any other good way of doing it?. Also if we add secondary index then i believe it should not be done at runtime due to performance hit. I am trying to use aerospike as a cache in my application.



Have you looked at the List functionality in Aerospike 3.7 ? That can be used to cover some of the cases you’re talking about, if you really want a list.

The parallel structure - Map - including different forms of in-database searching and sorting, are in dev. Please contact me at if you’d like to be considered as a beta user, we’re looking for feedback.


Thanks Brian for the reply.

I think I definitely need parallel structure in order to maintain the relation between key and its corresponding value counter. I am trying with 2 set right now.