rename txn.set to txn.put

Signed-off-by: ekexium <ekexium@gmail.com>
This commit is contained in:
ekexium 2020-09-22 10:50:17 +08:00
parent 796cfbaa79
commit 475fe54194
3 changed files with 6 additions and 6 deletions

View File

@ -9,7 +9,7 @@ async fn puts(client: &Client, pairs: impl IntoIterator<Item = impl Into<KvPair>
let mut txn = client.begin().await.expect("Could not begin a transaction"); let mut txn = client.begin().await.expect("Could not begin a transaction");
for pair in pairs { for pair in pairs {
let (key, value) = pair.into().into(); let (key, value) = pair.into().into();
txn.set(key, value).await.expect("Could not set key value"); txn.put(key, value).await.expect("Could not set key value");
} }
txn.commit().await.expect("Could not commit transaction"); txn.commit().await.expect("Could not commit transaction");
} }

View File

@ -154,12 +154,12 @@ impl Transaction {
/// let mut txn = client.begin().await.unwrap(); /// let mut txn = client.begin().await.unwrap();
/// let key = "TiKV".to_owned(); /// let key = "TiKV".to_owned();
/// let val = "TiKV".to_owned(); /// let val = "TiKV".to_owned();
/// txn.set(key, val); /// txn.put(key, val);
/// // Finish the transaction... /// // Finish the transaction...
/// txn.commit().await.unwrap(); /// txn.commit().await.unwrap();
/// # }); /// # });
/// ``` /// ```
pub async fn set(&self, key: impl Into<Key>, value: impl Into<Value>) -> Result<()> { pub async fn put(&self, key: impl Into<Key>, value: impl Into<Value>) -> Result<()> {
self.buffer.put(key.into(), value.into()); self.buffer.put(key.into(), value.into());
Ok(()) Ok(())
} }

View File

@ -40,8 +40,8 @@ async fn crud() -> Fallible<()> {
0 0
); );
txn.set("foo".to_owned(), "bar".to_owned()).await?; txn.put("foo".to_owned(), "bar".to_owned()).await?;
txn.set("bar".to_owned(), "foo".to_owned()).await?; txn.put("bar".to_owned(), "foo".to_owned()).await?;
// Read buffered values // Read buffered values
assert_eq!( assert_eq!(
txn.get("foo".to_owned()).await?, txn.get("foo".to_owned()).await?,
@ -81,7 +81,7 @@ async fn crud() -> Fallible<()> {
batch_get_res.get(&Key::from("bar".to_owned())), batch_get_res.get(&Key::from("bar".to_owned())),
Some(Value::from("foo".to_owned())).as_ref() Some(Value::from("foo".to_owned())).as_ref()
); );
txn.set("foo".to_owned(), "foo".to_owned()).await?; txn.put("foo".to_owned(), "foo".to_owned()).await?;
txn.delete("bar".to_owned()).await?; txn.delete("bar".to_owned()).await?;
txn.commit().await?; txn.commit().await?;