2
0
mirror of https://github.com/boostorg/redis.git synced 2026-01-19 04:42:09 +00:00
Files
redis/group__async.html
Marcelo Zimbres 9ea19dd5dc v1.0.0
2022-08-21 13:08:26 +02:00

394 lines
22 KiB
HTML

<!-- HTML header for doxygen 1.8.14-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Aedis: Asynchronous functions</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function() { init_search(); });
/* @license-end */
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="aedis.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table bgcolor="#346295" cellspacing="0" cellpadding="6">
<tbody>
<tr>
<td valign="middle" style="color: #FFFFFF" nowrap="nowrap"><font size="6">Aedis 0.3.0</font> &#160; <br> High level Redis client </td>
<td style="width:100%"> <div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.svg"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">Asynchronous functions</div> </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga74065e41d97eb1388f3d081b3195c4ff"><td class="memTemplParams" colspan="2">template&lt;class Adapter = detail::response_traits&lt;void&gt;::adapter_type, class CompletionToken = default_completion_token_type&gt; </td></tr>
<tr class="memitem:ga74065e41d97eb1388f3d081b3195c4ff"><td class="memTemplItemLeft" align="right" valign="top">auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__async.html#ga74065e41d97eb1388f3d081b3195c4ff">aedis::connection&lt; AsyncReadWriteStream &gt;::async_exec</a> (<a class="el" href="classaedis_1_1resp3_1_1request.html">resp3::request</a> const &amp;req, Adapter adapter=adapt(), CompletionToken token=CompletionToken{})</td></tr>
<tr class="memdesc:ga74065e41d97eb1388f3d081b3195c4ff"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes a command on the redis server asynchronously. <a href="group__async.html#ga74065e41d97eb1388f3d081b3195c4ff">More...</a><br /></td></tr>
<tr class="separator:ga74065e41d97eb1388f3d081b3195c4ff"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga42dce52942ebc5077f8b020189c71eed"><td class="memTemplParams" colspan="2">template&lt;class CompletionToken = default_completion_token_type&gt; </td></tr>
<tr class="memitem:ga42dce52942ebc5077f8b020189c71eed"><td class="memTemplItemLeft" align="right" valign="top">auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__async.html#ga42dce52942ebc5077f8b020189c71eed">aedis::connection&lt; AsyncReadWriteStream &gt;::async_receive_event</a> (CompletionToken token=CompletionToken{})</td></tr>
<tr class="memdesc:ga42dce52942ebc5077f8b020189c71eed"><td class="mdescLeft">&#160;</td><td class="mdescRight">Receives internal events. <a href="group__async.html#ga42dce52942ebc5077f8b020189c71eed">More...</a><br /></td></tr>
<tr class="separator:ga42dce52942ebc5077f8b020189c71eed"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga64109cde6ce5eb31aa36ff85cc43ce95"><td class="memTemplParams" colspan="2">template&lt;class Adapter = detail::response_traits&lt;void&gt;::adapter_type, class CompletionToken = default_completion_token_type&gt; </td></tr>
<tr class="memitem:ga64109cde6ce5eb31aa36ff85cc43ce95"><td class="memTemplItemLeft" align="right" valign="top">auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__async.html#ga64109cde6ce5eb31aa36ff85cc43ce95">aedis::connection&lt; AsyncReadWriteStream &gt;::async_receive_push</a> (Adapter adapter=adapt(), CompletionToken token=CompletionToken{})</td></tr>
<tr class="memdesc:ga64109cde6ce5eb31aa36ff85cc43ce95"><td class="mdescLeft">&#160;</td><td class="mdescRight">Receives unsolicited events asynchronously. <a href="group__async.html#ga64109cde6ce5eb31aa36ff85cc43ce95">More...</a><br /></td></tr>
<tr class="separator:ga64109cde6ce5eb31aa36ff85cc43ce95"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7e1e03893cd5992d50577e353fbc304a"><td class="memTemplParams" colspan="2">template&lt;class CompletionToken = default_completion_token_type&gt; </td></tr>
<tr class="memitem:ga7e1e03893cd5992d50577e353fbc304a"><td class="memTemplItemLeft" align="right" valign="top">auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__async.html#ga7e1e03893cd5992d50577e353fbc304a">aedis::connection&lt; AsyncReadWriteStream &gt;::async_run</a> (CompletionToken token=CompletionToken{})</td></tr>
<tr class="memdesc:ga7e1e03893cd5992d50577e353fbc304a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Starts communication with the Redis server asynchronously. <a href="group__async.html#ga7e1e03893cd5992d50577e353fbc304a">More...</a><br /></td></tr>
<tr class="separator:ga7e1e03893cd5992d50577e353fbc304a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0f864c4fc3f4d05001915bf7e9f8c59e"><td class="memTemplParams" colspan="2">template&lt;class Adapter = detail::response_traits&lt;void&gt;::adapter_type, class CompletionToken = default_completion_token_type&gt; </td></tr>
<tr class="memitem:ga0f864c4fc3f4d05001915bf7e9f8c59e"><td class="memTemplItemLeft" align="right" valign="top">auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__async.html#ga0f864c4fc3f4d05001915bf7e9f8c59e">aedis::connection&lt; AsyncReadWriteStream &gt;::async_run</a> (<a class="el" href="classaedis_1_1resp3_1_1request.html">resp3::request</a> const &amp;req, Adapter adapter=adapt(), CompletionToken token=CompletionToken{})</td></tr>
<tr class="memdesc:ga0f864c4fc3f4d05001915bf7e9f8c59e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Connects and executes a request asynchronously. <a href="group__async.html#ga0f864c4fc3f4d05001915bf7e9f8c59e">More...</a><br /></td></tr>
<tr class="separator:ga0f864c4fc3f4d05001915bf7e9f8c59e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga74065e41d97eb1388f3d081b3195c4ff"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga74065e41d97eb1388f3d081b3195c4ff">&#9670;&nbsp;</a></span>async_exec()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class AsyncReadWriteStream = boost::asio::ip::tcp::socket&gt; </div>
<div class="memtemplate">
template&lt;class Adapter = detail::response_traits&lt;void&gt;::adapter_type, class CompletionToken = default_completion_token_type&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">auto <a class="el" href="classaedis_1_1connection.html">aedis::connection</a>&lt; AsyncReadWriteStream &gt;::async_exec </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classaedis_1_1resp3_1_1request.html">resp3::request</a> const &amp;&#160;</td>
<td class="paramname"><em>req</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">Adapter&#160;</td>
<td class="paramname"><em>adapter</em> = <code>adapt()</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">CompletionToken&#160;</td>
<td class="paramname"><em>token</em> = <code>CompletionToken{}</code>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Executes a command on the redis server asynchronously. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">req</td><td>Request object. </td></tr>
<tr><td class="paramname">adapter</td><td>Response adapter. </td></tr>
<tr><td class="paramname">token</td><td>Asio completion token.</td></tr>
</table>
</dd>
</dl>
<p>For an example see <a class="el" href="echo__server_8cpp_source.html">echo_server.cpp</a>. The completion token must have the following signature</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> f(boost::system::error_code, std::size_t);</div>
</div><!-- fragment --><p>Where the second parameter is the size of the response in bytes. </p>
<p class="definition">Definition at line <a class="el" href="connection_8hpp_source.html#l00221">221</a> of file <a class="el" href="connection_8hpp_source.html">connection.hpp</a>.</p>
</div>
</div>
<a id="ga42dce52942ebc5077f8b020189c71eed"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga42dce52942ebc5077f8b020189c71eed">&#9670;&nbsp;</a></span>async_receive_event()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class AsyncReadWriteStream = boost::asio::ip::tcp::socket&gt; </div>
<div class="memtemplate">
template&lt;class CompletionToken = default_completion_token_type&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">auto <a class="el" href="classaedis_1_1connection.html">aedis::connection</a>&lt; AsyncReadWriteStream &gt;::async_receive_event </td>
<td>(</td>
<td class="paramtype">CompletionToken&#160;</td>
<td class="paramname"><em>token</em> = <code>CompletionToken{}</code></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Receives internal events. </p>
<p>See enum <code>events</code> for a list of events.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">token</td><td>The Asio completion token.</td></tr>
</table>
</dd>
</dl>
<p>The completion token must have the following signature</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> f(boost::system::error_code, <a class="code" href="classaedis_1_1connection.html#a33c7f3484cebc96ef3050407daded0c9">event</a>);</div>
<div class="ttc" id="aclassaedis_1_1connection_html_a33c7f3484cebc96ef3050407daded0c9"><div class="ttname"><a href="classaedis_1_1connection.html#a33c7f3484cebc96ef3050407daded0c9">aedis::connection::event</a></div><div class="ttdeci">event</div><div class="ttdoc">Events communicated through async_receive_event.</div><div class="ttdef"><b>Definition:</b> <a href="connection_8hpp_source.html#l00093">connection.hpp:93</a></div></div>
</div><!-- fragment -->
<p class="definition">Definition at line <a class="el" href="connection_8hpp_source.html#l00316">316</a> of file <a class="el" href="connection_8hpp_source.html">connection.hpp</a>.</p>
</div>
</div>
<a id="ga64109cde6ce5eb31aa36ff85cc43ce95"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga64109cde6ce5eb31aa36ff85cc43ce95">&#9670;&nbsp;</a></span>async_receive_push()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class AsyncReadWriteStream = boost::asio::ip::tcp::socket&gt; </div>
<div class="memtemplate">
template&lt;class Adapter = detail::response_traits&lt;void&gt;::adapter_type, class CompletionToken = default_completion_token_type&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">auto <a class="el" href="classaedis_1_1connection.html">aedis::connection</a>&lt; AsyncReadWriteStream &gt;::async_receive_push </td>
<td>(</td>
<td class="paramtype">Adapter&#160;</td>
<td class="paramname"><em>adapter</em> = <code>adapt()</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">CompletionToken&#160;</td>
<td class="paramname"><em>token</em> = <code>CompletionToken{}</code>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Receives unsolicited events asynchronously. </p>
<p>Users that expect unsolicited events should call this function in a loop. If an unsolicited events comes in and there is no reader, the connection will hang and eventually timeout.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">adapter</td><td>The response adapter. </td></tr>
<tr><td class="paramname">token</td><td>The Asio completion token.</td></tr>
</table>
</dd>
</dl>
<p>For an example see <a class="el" href="subscriber_8cpp_source.html">subscriber.cpp</a>. The completion token must have the following signature</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> f(boost::system::error_code, std::size_t);</div>
</div><!-- fragment -->
<p class="definition">Definition at line <a class="el" href="connection_8hpp_source.html#l00286">286</a> of file <a class="el" href="connection_8hpp_source.html">connection.hpp</a>.</p>
</div>
</div>
<a id="ga7e1e03893cd5992d50577e353fbc304a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga7e1e03893cd5992d50577e353fbc304a">&#9670;&nbsp;</a></span>async_run() <span class="overload">[1/2]</span></h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class AsyncReadWriteStream = boost::asio::ip::tcp::socket&gt; </div>
<div class="memtemplate">
template&lt;class CompletionToken = default_completion_token_type&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">auto <a class="el" href="classaedis_1_1connection.html">aedis::connection</a>&lt; AsyncReadWriteStream &gt;::async_run </td>
<td>(</td>
<td class="paramtype">CompletionToken&#160;</td>
<td class="paramname"><em>token</em> = <code>CompletionToken{}</code></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Starts communication with the Redis server asynchronously. </p>
<p>This function performs the following steps</p>
<ul>
<li>Resolves the Redis host as of <code>async_resolve</code> with the timeout passed in <a class="el" href="classaedis_1_1connection.html#a650fc6a2f21aaba6e3be507c97da3719" title="Timeout of the resolve operation.">connection::config::resolve_timeout</a>.</li>
</ul>
<ul>
<li>Connects to one of the endpoints returned by the resolve operation with the timeout passed in <a class="el" href="classaedis_1_1connection.html#ac6fd3112b27aa0e4df91fdc20535ed6d" title="Timeout of the connect operation.">connection::config::connect_timeout</a>.</li>
</ul>
<ul>
<li>Starts the idle check operation with the timeout of twice the value of <a class="el" href="classaedis_1_1connection.html#ab993911f199fc44b4a16db7b5a6af220" title="Time interval ping operations.">connection::config::ping_interval</a>. If no data is received during that time interval <code>async_run</code> completes with <a class="el" href="group__any.html#gga1833aa5e140bbaa9d319ecb1a71bd8baaa89ad1b8aaa085e108ffd59e1b60c232" title="Idle timeout.">error::idle_timeout</a>.</li>
</ul>
<ul>
<li>Starts the healthy check operation that sends command::ping to Redis with a frequency equal to <a class="el" href="classaedis_1_1connection.html#ab993911f199fc44b4a16db7b5a6af220" title="Time interval ping operations.">connection::config::ping_interval</a>.</li>
</ul>
<ul>
<li>Starts reading from the socket and delivering events to the request started with <code>async_exec</code> and <code>async_receive_event</code>.</li>
</ul>
<p>For an example see <a class="el" href="echo__server_8cpp_source.html">echo_server.cpp</a>.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">token</td><td>Completion token.</td></tr>
</table>
</dd>
</dl>
<p>The completion token must have the following signature</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> f(boost::system::error_code);</div>
</div><!-- fragment --><dl class="section return"><dt>Returns</dt><dd>This function returns only when there is an error. </dd></dl>
<p class="definition">Definition at line <a class="el" href="connection_8hpp_source.html#l00194">194</a> of file <a class="el" href="connection_8hpp_source.html">connection.hpp</a>.</p>
</div>
</div>
<a id="ga0f864c4fc3f4d05001915bf7e9f8c59e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga0f864c4fc3f4d05001915bf7e9f8c59e">&#9670;&nbsp;</a></span>async_run() <span class="overload">[2/2]</span></h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class AsyncReadWriteStream = boost::asio::ip::tcp::socket&gt; </div>
<div class="memtemplate">
template&lt;class Adapter = detail::response_traits&lt;void&gt;::adapter_type, class CompletionToken = default_completion_token_type&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">auto <a class="el" href="classaedis_1_1connection.html">aedis::connection</a>&lt; AsyncReadWriteStream &gt;::async_run </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classaedis_1_1resp3_1_1request.html">resp3::request</a> const &amp;&#160;</td>
<td class="paramname"><em>req</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">Adapter&#160;</td>
<td class="paramname"><em>adapter</em> = <code>adapt()</code>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">CompletionToken&#160;</td>
<td class="paramname"><em>token</em> = <code>CompletionToken{}</code>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Connects and executes a request asynchronously. </p>
<p>Combines <code>async_run</code> and the other <code>async_exec</code> overload in a single function. This function is useful for users that want to send a single request to the server and close it.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">req</td><td>Request object. </td></tr>
<tr><td class="paramname">adapter</td><td>Response adapter. </td></tr>
<tr><td class="paramname">token</td><td>Asio completion token.</td></tr>
</table>
</dd>
</dl>
<p>For an example see <a class="el" href="intro_8cpp_source.html">intro.cpp</a>. The completion token must have the following signature</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> f(boost::system::error_code, std::size_t);</div>
</div><!-- fragment --><p>Where the second parameter is the size of the response in bytes. </p>
<p class="definition">Definition at line <a class="el" href="connection_8hpp_source.html#l00255">255</a> of file <a class="el" href="connection_8hpp_source.html">connection.hpp</a>.</p>
</div>
</div>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.14-->
<!-- start footer part -->
<hr class="footer"/><address class="footer">
Author: Marcelo Zimbres Silva.
</address>
</body>
</html>