mirror of
https://github.com/boostorg/redis.git
synced 2026-01-19 04:42:09 +00:00
Adds more doc to node class.
This commit is contained in:
20
README.md
20
README.md
@@ -6,18 +6,18 @@ that implements the latest version of the Redis communication
|
||||
protocol
|
||||
[RESP3](https://github.com/redis/redis-specifications/blob/master/protocol/RESP3.md).
|
||||
It makes communication with a Redis server easy by hiding low-level
|
||||
Asio-related code away from the user, which, in the majority of the
|
||||
cases will be concerned with only three library entities
|
||||
code away from the user, which, in the majority of the cases will be
|
||||
concerned with only three library entities
|
||||
|
||||
* `aedis::connection`: A connection to the Redis server that
|
||||
implements automatic
|
||||
[pipelining](https://redis.io/docs/manual/pipelining/) and which can
|
||||
handle requests and server pushes concurrently.
|
||||
* `aedis::connection`: A connection to the Redis server with
|
||||
high-level functions to execute Redis commands, receive server
|
||||
pushes and support for automatic command
|
||||
[pipelines](https://redis.io/docs/manual/pipelining/).
|
||||
* `aedis::resp3::request`: A container of Redis commands that supports
|
||||
STL containers and user defined data types.
|
||||
* `aedis::adapt()`: A function that adapts data structures to receive responses.
|
||||
|
||||
In the next sections we will cover all those points in detail and with
|
||||
In the next sections we will cover all those points in detail with
|
||||
examples. The requirements for using Aedis are
|
||||
|
||||
* Boost 1.80 or greater.
|
||||
@@ -53,7 +53,7 @@ auto co_main() -> net::awaitable<void>
|
||||
// From examples/common.hpp to avoid vebosity
|
||||
co_await connect(conn, "127.0.0.1", "6379");
|
||||
|
||||
// A request can contains multiple commands.
|
||||
// A request can contain multiple commands.
|
||||
resp3::request req;
|
||||
req.push("HELLO", 3);
|
||||
req.push("HGETALL", "hset-key");
|
||||
@@ -71,8 +71,8 @@ auto co_main() -> net::awaitable<void>
|
||||
```
|
||||
|
||||
The example above uses the Asio awaitable `operator ||` to compose
|
||||
`connection::async_exec` and `connection::async_run` in a single
|
||||
operation we can `co_await` on. It also provides cancelation one of
|
||||
`connection::async_exec` and `connection::async_run` in an
|
||||
operation we can `co_await` on. It also provides cancelation of one of
|
||||
the operations when the other completes. The role played by these
|
||||
functions are
|
||||
|
||||
|
||||
@@ -14,11 +14,33 @@ namespace aedis::resp3 {
|
||||
/** \brief A node in the response tree.
|
||||
* \ingroup high-level-api
|
||||
*
|
||||
* Redis responses are the pre-order view of the response tree (see
|
||||
* https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR).
|
||||
* RESP3 can contain recursive data structures: A map of sets of
|
||||
* vector of etc. As it is parsed each element is passed to user
|
||||
* callbacks (push parser), the `aedis::adapt` function. The signature of this
|
||||
* callback is `f(resp3::node<std::string_view)`. This class is called a node
|
||||
* because it can be seen as the element of the response tree. It
|
||||
* is a template so that users can use it with owing strings e.g.
|
||||
* `std::string` or `boost::static_string` etc. if they decide to use a node as
|
||||
* response type, for example, to read a non-aggregate data-type use
|
||||
*
|
||||
* \remark Any Redis response can be received in an array of nodes,
|
||||
* for example \c std::vector<node<std::string>>.
|
||||
* ```cpp
|
||||
* resp3::node<std::string> resp;
|
||||
* co_await conn->async_exec(req, adapt(resp));
|
||||
* ```
|
||||
*
|
||||
* for an aggregate use instead
|
||||
*
|
||||
* ```cpp
|
||||
* std::vector<resp3::node<std::string>> resp; co_await
|
||||
* conn->async_exec(req, adapt(resp));
|
||||
* ```
|
||||
*
|
||||
* The vector will contain the
|
||||
* [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
|
||||
* view of the response tree. Any Redis response can be received in
|
||||
* an array of nodes as shown above.
|
||||
*
|
||||
* \tparam String A `std::string`-like type.
|
||||
*/
|
||||
template <class String>
|
||||
struct node {
|
||||
|
||||
Reference in New Issue
Block a user