I’ve got a record with an ordered list bin, the only access pattern for the set so far was to append values to the ordered list bin via AerospikeClient#operate method. I’ve stumbled upon a requirement to be able to completely replace a record. I’ve tried to pass a WritePolicy instance with RecordExistsAction.REPLACE recordExistsAction specified which resulted in an error:
The only option for me is to delete a record first and then call an operate method to append values to an ordered list, but I’d like to avoid an extra network call to the Aerospike server as much as possible. Are there any other options available to solve my issue?
WritePolicy wPolicy = new WritePolicy();
wPolicy.recordExistsAction = RecordExistsAction.REPLACE;
Key key = new Key("test", "users", username);
Bin bin1 = new Bin("interests",
Arrays.asList(interests.split(","))); //interests is string of csv e.g. "flying, hiking, walking"
client.put(wPolicy, key, bin1);
ListOperations are intended for modifying an existing List Bin - so they are only allowed for UPDATE action. If you want to REPLACE an existing record, then don’t go the List Modification route. Write a list bin directly using client.put().
thank you!
Actually the “policy” method argument was a source of confusion for me. If it’s not intended to be different than a single value, it would be nice to exclude it from the list of arguments, wouldn’t it?