Module ping

Source
Expand description

Abstraction of PING command.

For general information about this command, see the Redis documentation.

§Basic usage (client shorthand)

Internally it is checked whether the server answers with PONG. If not, an error is returned.

let mut stack = Stack::default();
let clock = StandardClock::default();

let mut connection_handler = ConnectionHandler::resp2(SocketAddr::from_str("127.0.0.1:6379").unwrap());
let client = connection_handler.connect(&mut stack, Some(&clock)).unwrap();

let response = client.ping().unwrap().wait().unwrap();

§Verbose command

Sending a PingCommand as alternative to client shorthand.

let command = PingCommand::new(None);
let response = client.send(command).unwrap().wait().unwrap();

§Custom argument

Optionally, a user-defined argument can be specified.

The abstraction compares the server’s response with the argument and returns an error if there is no match.

let command = PingCommand::new(Some("hello world".into()));
let response = client.send(command).unwrap().wait().unwrap();

Structs§

PingCommand
Abstraction for PING command