You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+41-20Lines changed: 41 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,21 +42,30 @@ auto async_main() -> net::awaitable<void>
42
42
```
43
43
44
44
The execution of `connection::async_exec` above is composed with
45
-
`connection::async_run` with the aid of the Asio awaitable operator ||
45
+
`connection::async_run` with the aid of the Asio awaitable `operator ||`
46
46
that ensures that one operation is cancelled as soon as the other
47
47
completes, these functions play the following roles
48
48
49
-
*`connection::async_exec`: Execute commands (i.e. write the request and reads the response).
50
-
*`connection::async_run`: Coordinate read and write operations and remains suspended until the connection is lost.
49
+
*`connection::async_exec`: Execute commands by writing the request payload to the underlying stream and reading the response sent back by Redis. It can be called from multiple places in your code concurrently.
50
+
*`connection::async_run`: Coordinate the low-level IO (read and write) operations and remains suspended until the connection is lost.
51
51
52
-
Let us dig in.
52
+
When a connection is lost, the `async_exec` calls won't automatically
53
+
fail, instead, they will remain suspended until they are either all
54
+
canceled with a call to `connection::cancel(operation::exec)` or a new
55
+
connection is established and `async_run` is called again, in which
56
+
case they will be resent automatically. Users can customise this
57
+
behaviour by carefully choosing the values of
58
+
`aedis::resp3::request::config`. The role played by `async_run`
59
+
becomes clearer with long-lived connections, which we will cover
60
+
in the next section.
53
61
54
62
<aname="connection"></a>
55
63
## Connection
56
64
57
-
In general we will want to reuse the same connection for multiple
58
-
requests, we can do this with the example above by decoupling the
59
-
HELLO command and the call to `async_run` in a separate coroutine
65
+
For performance reasons we will usually want to perform multiple
66
+
requests on the same connection. We can do this with the example above
67
+
by decoupling the HELLO command and the call to `async_run` in a
0 commit comments