mirror of https://github.com/tikv/client-rust.git
parent
da63451caf
commit
6e8eef7fcf
|
|
@ -58,7 +58,10 @@ async fn main() {
|
||||||
let value3: Value = b"value3".to_vec();
|
let value3: Value = b"value3".to_vec();
|
||||||
txn1.put(key1.clone(), value3).await.unwrap();
|
txn1.put(key1.clone(), value3).await.unwrap();
|
||||||
txn1.commit().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();
|
let result = txn3.get(key1.clone()).await.unwrap().unwrap();
|
||||||
|
txn3.commit()
|
||||||
|
.await
|
||||||
|
.expect("Committing read-only transaction should not fail");
|
||||||
println!("{:?}", (key1, result));
|
println!("{:?}", (key1, result));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,12 @@ async fn puts(client: &Client, pairs: impl IntoIterator<Item = impl Into<KvPair>
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get(client: &Client, key: Key) -> Option<Value> {
|
async fn get(client: &Client, key: Key) -> Option<Value> {
|
||||||
let txn = client.begin().await.expect("Could not begin a transaction");
|
let mut txn = client.begin().await.expect("Could not begin a transaction");
|
||||||
txn.get(key).await.expect("Could not get value")
|
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<BoundRange>, limit: u32) {
|
async fn scan(client: &Client, range: impl Into<BoundRange>, limit: u32) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue