Open
Description
Description
Give the python client access to the Redis command CONFIG RESETSTAT by exposing it through the Pybindings.
Justification
The user will be able to reset the statistics reported by Redis using the INFO command.
Implementation Strategy
This implementation will be very similar to that of CONFIG SET
and will be an AddressAtCommand
.
The implementation will look something like this in client.cpp
:
std::string Client::config_resetstat()
{
std::string host = address.substr(0, address.find(":"));
uint64_t port = std::stoul(address.substr(address.find(":") + 1),
nullptr, 0);
if (host.empty() or port == 0){
throw std::runtime_error(std::string(address) +
"is not a valid database node address.");
}
AddressAtCommand cmd;
cmd.set_exec_address_port(host, port);
cmd.add_field("CONFIG");
cmd.add_field("RESETSTAT");
CommandReply reply = _run(cmd);
if (reply.has_error() > 0)
throw std::runtime_error("CONFIG RESETSTAT command failed");
return std::string(reply.status_str(), reply.status_str_len());
}
This functionality then needs to be exposed through the Pybindings
and pyclient.cpp
file to the python client layer. For testing on the python client, call CONFIG RESET
and then INFO
and check that parameters like Keyspace hits, Keyspace misses, Number of commands processed, ect. are reset. For unit testing, make sure an invalid address throws an error.