I’ve tried to reproduce the example you’ve provided, and it indeed crashes, something it shouldn’t be doing: http://issues.couchbase.com/browse/PYCBC-302 (this is an input validation bug, your example would still fail with an exception if the bug was fixed).
In any event, you should create an Item instance separately, like so:
The idea behind the Item is that properties bound to the specific document (such as key, value, and cas) remain part of the item, and therefore cas is not an option to the command but rather a property of the input itself.
I might add a create_and_add() method as well, which would let you do what you are doing (as it is indeed the only way to specify CAS in a *multi command)
Cool, Thank you for your fast reply!
I tested it and it worked nicely
For those who are interested: I write it down here because I could not find it in the documentation:
if set_multi fails on a document due to an out-of-date CAS value, it will throw an Error (KeyExistsError err) where err.all_results provides a MultiResult, i.e., you can check individually for each document if it succeeded or not.