Write Generation Policy - Multi threaded application

All,

In a multi threaded application, where writes have to be done in parallel, how can you implement “GEN_EQUAL” policy? We cannot use the same WritePolicy object because any other thread can update the “generation” value before the “put” happens for that record.

Another option would be to create a “WritePolicy” object for each record, but this will end up with “n” number of WritePolicy objects for n records.

Any help is appreciated.

Thanks.

In Python, the generation value to check against is specified separately in the meta argument. See here. In Java, it is part of the WritePolicy object. A write-specific WritePolicy can be constructed from a global WritePolicy object and the correct write-specific generation assigned to it. As you point out, in this case, you will need as many WritePolicy objects as concurrent writes. This should not pose any problem. Please let us know if you think there would be or experience any issues.

© 2021 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.