multiAndExec method
multiAndExec takes function to complete CAS as Transaction passed function takes Transaction as only parameter and should be used to complete transaction
!!! DO NOT call exec() on Transaction
Implementation
Future multiAndExec(Future func(Transation)) {
return _cmd.multi().then((Transaction _trans) {
func(_trans);
return _trans.exec().then((var resp) {
if (resp == "OK") {
_completer_bool.complete(false); //terminate Future.doWhile
} else {
// exec completes only with valid response
_completer_bool.completeError(
RedisError("exec response is not expected, but is $resp"));
}
}).catchError((e) {
// dont do anything
_completer_bool.complete(true); // retry
}, test: (e) => e is TransactionError);
});
}