mirror of
https://github.com/boostorg/redis.git
synced 2026-01-19 16:52:08 +00:00
- Moves response classes to their own header. - aedis.hpp used only to include other headers like in boost. - Removes buffer typedef. - Events example. - Async example. - Improvements in the makefile. - Adds reconnect example.
39 lines
933 B
C++
39 lines
933 B
C++
/* Copyright (c) 2019 - 2020 Marcelo Zimbres Silva (mzimbres at gmail dot com)
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#include <aedis/aedis.hpp>
|
|
|
|
namespace net = aedis::net;
|
|
|
|
using namespace net;
|
|
using namespace aedis;
|
|
|
|
int main()
|
|
{
|
|
try {
|
|
resp::pipeline p;
|
|
p.set("Password", {"12345"});
|
|
p.quit();
|
|
|
|
io_context ioc {1};
|
|
tcp::resolver resv(ioc);
|
|
tcp::socket socket {ioc};
|
|
net::connect(socket, resv.resolve("127.0.0.1", "6379"));
|
|
net::write(socket, buffer(p.payload));
|
|
|
|
std::string buffer;
|
|
for (;;) {
|
|
resp::response_string res;
|
|
resp::read(socket, buffer, res);
|
|
std::cout << res.result << std::endl;
|
|
}
|
|
} catch (std::exception const& e) {
|
|
std::cerr << e.what() << std::endl;
|
|
}
|
|
}
|
|
|