2
0
mirror of https://github.com/boostorg/redis.git synced 2026-02-10 23:52:20 +00:00
2020-12-12 15:57:46 +01:00
2020-11-28 21:24:11 +01:00
2020-12-12 15:57:46 +01:00
2020-09-19 10:55:46 +02:00
2019-11-19 22:19:03 +01:00
2020-12-12 15:57:46 +01:00
2020-11-29 09:45:54 +01:00

Aedis

Aedis is a redis client designed for seamless integration with async code while providing a easy and intuitive interface. To use this library include aedis.hpp in your project.

Examples

The examples below will use coroutines, callbacks and futures are supported as well.

Basics

Below a basic example

net::awaitable<void> example1()
{
   auto ex = co_await this_coro::executor;

   tcp::resolver resv(ex);
   auto const r = resv.resolve("127.0.0.1", "6379");

   tcp_socket socket {ex};
   co_await async_connect(socket, r);

   std::map<std::string, std::string> map
   { {{"Name"},      {"Marcelo"}} 
   , {{"Education"}, {"Physics"}}
   , {{"Job"},       {"Programmer"}}
   };

   resp::pipeline p;
   p.hset("map", map);
   p.hincrby("map", "Age", 40);
   p.hmget("map", {"Name", "Education", "Job"});
   p.quit();

   co_await async_write(socket, buffer(p.payload));

   resp::buffer buffer;
   for (;;) {
      resp::response res;
      co_await resp::async_read(socket, buffer, res);
      resp::print(res.res);
   }
}

Though short the example above ilustrates many important points

  • STL containers are suported when appropriate.
  • Commands are sent to redis in pipeline to improve performance.
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%