diff --git a/examples/pessimistic.rs b/examples/pessimistic.rs index 06e8427..bca0fc7 100644 --- a/examples/pessimistic.rs +++ b/examples/pessimistic.rs @@ -58,7 +58,10 @@ async fn main() { let value3: Value = b"value3".to_vec(); txn1.put(key1.clone(), value3).await.unwrap(); txn1.commit().await.unwrap(); - let txn3 = client.begin().await.expect("Could not begin a transaction"); + let mut txn3 = client.begin().await.expect("Could not begin a transaction"); let result = txn3.get(key1.clone()).await.unwrap().unwrap(); + txn3.commit() + .await + .expect("Committing read-only transaction should not fail"); println!("{:?}", (key1, result)); } diff --git a/examples/transaction.rs b/examples/transaction.rs index f56c051..d089be3 100644 --- a/examples/transaction.rs +++ b/examples/transaction.rs @@ -15,8 +15,12 @@ async fn puts(client: &Client, pairs: impl IntoIterator } async fn get(client: &Client, key: Key) -> Option { - let txn = client.begin().await.expect("Could not begin a transaction"); - txn.get(key).await.expect("Could not get value") + let mut txn = client.begin().await.expect("Could not begin a transaction"); + let res = txn.get(key).await.expect("Could not get value"); + txn.commit() + .await + .expect("Committing read-only transaction should not fail"); + res } async fn scan(client: &Client, range: impl Into, limit: u32) {