pub async fn ping(&mut self) -> Result<bool, CachemError> {
        self.0.get_mut().write_u8(Command::Ping.into()).await?;
        self.0.flush().await?;

        if u8::read(&mut self.0).await.is_ok() {
            Ok(true)
        } else {
            log::error!("Connection not healthy");
            Ok(false)
        }
    }
/// Sends a PING command to the server
///
/// # Returns
///
/// * `true` -> The server replied with PONG
/// * `false` -> The server did not reply
///
/// # Example
///
/// ```no_run
/// # use cachem::*;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// // creates a new pool with one connection
/// let pool = ConnectionPool::new("127.0.0.1:1337".into(), 1usize).await?;
/// // get a connection
/// let mut conn = pool.acquire().await?;
/// conn.ping().await?;
///
/// # Ok(())
/// # }
/// ```
Sends a PING command to the server
Sends a PING command to the server
pub async fn ping(&mut self) -> Result<bool, CachemError> {
        self.0.get_mut().write_u8(Command::Ping.into()).await?;
        self.0.flush().await?;
        if u8::read(&mut self.0).await.is_ok() {
            Ok(true)
        } else {
            log::error!("Connection not healthy");
            Ok(false)
        }
    }
pub async fn ping ( & mut self ) -> Result < bool , CachemError > { self . 0 . get_mut ( ) . write_u8 ( Command :: Ping . into ( ) ) . await ? ; self . 0 . flush ( ) . await ? ; if u8 :: read ( & mut self . 0 ) . await . is_ok ( ) { Ok ( true ) } else { log :: error ! ( " " ) ; Ok ( false ) } }
Sends a PING command to the server
Sends a PING command to the server
&mut self
`true` -> The server replied with PONG
`false` -> The server did not reply
` true ` - > The server replied with PONG ` false ` - > The server did not reply
&mut self
example
None
use cachem::*;
None
#[tokio::main]
None
async fn main() -> result<(), box<dyn std::error::error>> {
creates a new pool with one connection
let pool = ConnectionPool::new("127.0.0.1:1337".into(), 1usize).await?;
get a connection
let mut conn = pool.acquire().await?;
conn.ping().await?.
creates a new pool with one connection let pool = ConnectionPool :: new ( " 127 . 0 . 0 . 1 : 1337 " . into () 1usize ) . await? ; get a connection let mut conn = pool . acquire () . await? ; conn . ping () . await? .
ok(())
None
}
None