Rust client for keyz
- Import
use keyz_rust_client::{ Keyz };
- Initialize the connection to running keyz server
let keyz = Keyz::new("127.0.0.1".to_owned(), 7667).await;
- Set value where key is
test
and value is1
let result = keyz.set("test", "1", None).await.unwrap();
- Set value where key is
test
and value is1
with expiry time in secondslet req = keyz.set("test", "1", Some(20)).await.unwrap();
- Get value with key
test
let result = keyz.get("test").await.unwrap();
- Delete value with key
test
let result = keyz.delete("test").await.unwrap();
- Get the time left for the key
test
to expirelet result = keyz.expires_in("test").await.unwrap();
- Dispose connection
keyz.dispose().await.unwrap();
!!! Important make sure to dispose of connection when not needed anymore
let keyz = Keyz::new("127.0.0.1".to_owned(), 7667).await;
keyz.send_message("SET test 1").await.unwrap();
keyz.dispose().await.unwrap();
It is not advised to directly use this because some command currently are not fully supported with this method. You can learn more about all the commands in the keyz repo here