mirror of
https://github.com/boostorg/redis.git
synced 2026-02-10 23:52:20 +00:00
d1f4e69122cb1ef8bdf5773ad841960a1def14da
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
Languages
C++
96%
Python
1.4%
CMake
1.2%
Java
0.3%
Rust
0.3%
Other
0.7%