2
0
mirror of https://github.com/boostorg/redis.git synced 2026-02-02 21:12:16 +00:00
Marcelo Zimbres 05aff2f3c6 Refactoring listed below:
- Improvements in the organization.
- Adds support for the default token on the consumer.
2021-10-10 15:26:06 +02:00
2021-08-07 13:46:54 +02:00
2021-10-10 15:26:06 +02:00
2021-10-10 15:26:06 +02:00
2021-06-19 18:37:22 +02:00
2021-10-10 15:26:06 +02:00
2021-06-19 18:37:22 +02:00
2021-08-21 22:38:27 +02:00
2019-11-19 22:19:03 +01:00
2021-09-18 22:27:55 +02:00
2021-09-11 14:20:45 +02:00

Aedis

Aedis is a redis client designed for scalability and performance while providing an easy and intuitive interface.

Example

The general form of the read and write operations of a redis client that support push notifications and pipelines looks like the following

net::awaitable<void>
example(net::ip::tcp::socket& socket, std::queue<pipeline>& pipelines)
{
   pipelines.push({});
   pipelines.back().hello("3");

   std::string buffer;
   response_buffers buffers;
   response_adapters adapters{buffers};
   consumer_state cs;

   for (;;) {
      auto const type =
        co_await async_consume(
            socket, buffer, pipelines, adapters, cs, net::use_awaitable);

      if (type == resp3::type::push) {
         // Push received.
         continue;
      }

      auto const cmd = pipelines.front().commands.front();

      // Response to a specific command.
   }
}

The example above will start writing the hello command and proceed reading its response. After that users can add further commands to the queue. See the example directory for a complete example. The main function looks like this

int main()
{
   net::io_context ioc;
   net::ip::tcp::resolver resolver{ioc};
   auto const res = resolver.resolve("127.0.0.1", "6379");

   net::ip::tcp::socket socket{ioc};
   net::connect(socket, res);

   std::queue<pipeline> pipelines;
   co_spawn(ioc, example(socket, pipelines), net::detached);
   ioc.run();
}

See the examples directory for more examples.

Installation

This library is header only. To install it run

$ sudo make install

or copy the include folder to where you want. You will also need to include the following header in one of your source files e.g. aedis.cpp

#include <aedis/impl/src.hpp>
Description
Mirrored via gitea-mirror
Readme 6.7 MiB
Languages
C++ 96%
Python 1.4%
CMake 1.2%
Java 0.3%
Rust 0.3%
Other 0.7%