glide/commands/
connection_management.rs1use crate::ValkeyResult;
5use crate::cmd::Cmd;
6use crate::executor::CommandExecutor;
7use crate::value::FromValkeyValue;
8use crate::write::ToValkeyArgs;
9use async_trait::async_trait;
10use bytes::Bytes;
11
12#[async_trait]
14pub trait ConnectionManagementCommands: CommandExecutor {
15 async fn echo<M: ToValkeyArgs + Send>(&self, message: M) -> ValkeyResult<Bytes> {
17 let mut cmd = Cmd::new();
18 cmd.arg("ECHO").arg(message);
19 Bytes::from_owned_valkey_value(self.execute_command(cmd, None).await?)
20 }
21
22 async fn select(&self, index: i64) -> ValkeyResult<()> {
24 let mut cmd = Cmd::new();
25 cmd.arg("SELECT").arg(index);
26 <()>::from_owned_valkey_value(self.execute_command(cmd, None).await?)
27 }
28
29 async fn client_no_evict(&self, on: bool) -> ValkeyResult<()> {
31 let mut cmd = Cmd::new();
32 cmd.arg("CLIENT")
33 .arg("NO-EVICT")
34 .arg(if on { "ON" } else { "OFF" });
35 <()>::from_owned_valkey_value(self.execute_command(cmd, None).await?)
36 }
37
38 async fn client_no_touch(&self, on: bool) -> ValkeyResult<()> {
41 let mut cmd = Cmd::new();
42 cmd.arg("CLIENT")
43 .arg("NO-TOUCH")
44 .arg(if on { "ON" } else { "OFF" });
45 <()>::from_owned_valkey_value(self.execute_command(cmd, None).await?)
46 }
47
48 async fn reset(&self) -> ValkeyResult<()> {
50 let mut cmd = Cmd::new();
51 cmd.arg("RESET");
52 <()>::from_owned_valkey_value(self.execute_command(cmd, None).await?)
53 }
54}
55
56impl<T: CommandExecutor + ?Sized> ConnectionManagementCommands for T {}