Expand description
Abstraction of HGETALL command.
For general information about this command, see the Redis documentation.
§Using command object
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();
client.hset("test_all_hash", "color", "green").unwrap().wait().unwrap();
client.hset("test_all_hash", "material", "wood").unwrap().wait().unwrap();
let command = HashGetAllCommand::new("test_all_hash");
let response = client.send(command).unwrap().wait().unwrap().unwrap();
assert_eq!("green", response.get_str("color").unwrap());
assert_eq!("wood", response.get_str("material").unwrap());
§Missing key or field
In case key or field is missing. None is returned.
let command = HashGetAllCommand::new("not_existing");
let response = client.send(command).unwrap().wait().unwrap();
assert!(response.is_none())
§Shorthand
Client provides a shorthand method for this command.
// Using &str arguments
let response = client.hgetall("multi_hash_key").unwrap().wait().unwrap().unwrap();
assert_eq!("green", response.get_str("first_field").unwrap());
assert_eq!("wood", response.get_str("second_field").unwrap());
// Using String arguments
let _ = client.hgetall("multi_hash_key".to_string());
// Using Bytes arguments
let _ = client.hgetall(Bytes::from_static(b"multi_hash_key"));
Structs§
- Hash
GetAll Command - Abstraction for HGETALL command
- Hash
Response