2
0
mirror of https://github.com/boostorg/redis.git synced 2026-02-20 15:02:23 +00:00
Files
redis/examples/async_minimum.cpp
2021-02-07 12:34:57 +01:00

39 lines
1.1 KiB
C++

/* Copyright (c) 2019 - 2021 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 <boost/asio.hpp>
#include <aedis/aedis.hpp>
using namespace aedis;
/* This example shows the absolute minimum you need to stablish a
* connection with redis.
*
* 1. Write an enum class that defines your events.
*
* 2. Write a receiver. The receiver_base class below is not
* required if your receiver class supports the receiver
* concept.
*
* In the next examples we will see how to receive and write commands.
*/
enum class events {one, two, three, ignore};
struct receiver : public receiver_base<events> { };
int main()
{
net::io_context ioc {1};
net::ip::tcp::resolver resolver{ioc};
auto const results = resolver.resolve("127.0.0.1", "6379");
auto conn = std::make_shared<connection<events>>(ioc);
receiver recv;
conn->start(recv, results);
ioc.run();
}