2
0
mirror of https://github.com/boostorg/redis.git synced 2026-02-13 00:32:13 +00:00

Improvements in the examples.

This commit is contained in:
Marcelo Zimbres
2019-11-23 09:12:59 +01:00
parent f32514c0f2
commit b2d9efe8e9
3 changed files with 121 additions and 13 deletions

View File

@@ -20,7 +20,7 @@ void send(std::string cmd)
ioc.run();
}
int main(int argc, char* argv[])
void example1()
{
std::list<std::string> a
{"one" ,"two", "three"};
@@ -63,3 +63,58 @@ int main(int argc, char* argv[])
send(std::move(s));
}
void example2()
{
net::io_context ioc;
session::config cfg
{ "127.0.0.1" // host
, "6379" // port
, 256 // Max pipeline size
, std::chrono::milliseconds {500} // Connection retry
, {} // Sentinel addresses
, log::level::info
};
session s {ioc, cfg, "id"};
s.send(ping());
s.run();
ioc.run();
}
void example3()
{
net::io_context ioc;
session s {ioc};
s.set_on_conn_handler([]() {
std::cout << "Connected" << std::endl;
});
s.set_msg_handler([](auto ec, auto res) {
if (ec) {
std::cerr << "Error: " << ec.message() << std::endl;
}
std::copy( std::cbegin(res)
, std::cend(res)
, std::ostream_iterator<std::string>(std::cout, " "));
std::cout << std::endl;
});
s.send(ping());
s.run();
ioc.run();
}
int main(int argc, char* argv[])
{
example1();
//example2();
//example3();
}