.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "MONGOC_SESSION_OPTS_SET_CAUSAL_CONSISTENCY" "3" "May 07, 2024" "1.27.1" "libmongoc" .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 .sp .EX void mongoc_session_opts_set_causal_consistency (mongoc_session_opt_t *opts, bool causal_consistency); .EE .UNINDENT .UNINDENT .sp Configure causal consistency in a session. If true (the default), each operation in the session will be causally ordered after the previous read or write operation. Set to false to disable causal consistency. See \fI\%the MongoDB Manual Entry for Causal Consistency\fP\&. .sp Causal consistency and snapshot reads are mutually exclusive. Attempting to set both to true will result in an error. See \fI\%mongoc_session_opts_set_snapshot()\fP\&. .sp Unacknowledged writes are not causally consistent. If you execute a write operation with a \fI\%mongoc_write_concern_t\fP on which you have called \fI\%mongoc_write_concern_set_w()\fP with a value of 0, the write does not participate in causal consistency. .SH PARAMETERS .INDENT 0.0 .IP \(bu 2 \fBopts\fP: A \fI\%mongoc_session_opt_t\fP\&. .IP \(bu 2 \fBcausal_consistency\fP: True or false. .UNINDENT .SH EXAMPLE .INDENT 0.0 .INDENT 3.5 .sp .EX mongoc_client_t *client; mongoc_session_opt_t *session_opts; mongoc_client_session_t *client_session; mongoc_collection_t *collection; bson_t insert_opts = BSON_INITIALIZER; bson_t *doc; bson_error_t error; bool r; client = mongoc_client_new (\(dqmongodb://example/?appname=session\-opts\-example\(dq); mongoc_client_set_error_api (client, 2); session_opts = mongoc_session_opts_new (); mongoc_session_opts_set_causal_consistency (session_opts, false); client_session = mongoc_client_start_session (client, session_opts, &error); mongoc_session_opts_destroy (session_opts); if (!client_session) { fprintf (stderr, \(dqFailed to start session: %s\en\(dq, error.message); abort (); } collection = mongoc_client_get_collection (client, \(dqtest\(dq, \(dqcollection\(dq); doc = BCON_NEW (\(dq_id\(dq, BCON_INT32 (1)); r = mongoc_client_session_append (client_session, &insert_opts, NULL); if (!r) { fprintf (stderr, \(dqmongoc_client_session_append failed: %s\en\(dq, error.message); abort (); } r = mongoc_collection_insert_one ( collection, doc, &insert_opts, NULL /* reply */, &error); if (!r) { fprintf (stderr, \(dqInsert failed: %s\en\(dq, error.message); abort (); } .EE .UNINDENT .UNINDENT .SH AUTHOR MongoDB, Inc .SH COPYRIGHT 2017-present, MongoDB, Inc .\" Generated by docutils manpage writer. .