Skip to content

Commit

Permalink
[automated site update]
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Sep 3, 2024
1 parent 4c3a628 commit 832d863
Show file tree
Hide file tree
Showing 15 changed files with 168 additions and 154 deletions.
22 changes: 12 additions & 10 deletions apidoc/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ <h2><a class="anchor" id="autotoc_md3"></a>
<li><a class="el" href="index.html#simple-redis-queries">Simple Redis queries</a></li>
<li><a class="el" href="index.html#atomic-transaction-blocks-and-lua-scripts">Atomic execution blocks and LUA scripts</a></li>
<li><a class="el" href="index.html#publish-subscribe-support">Publish/subscribe (PUB/SUB) support</a></li>
<li><a class="el" href="index.html#implementing-further-redis-commands">Implementing further Redis commands</a></li>
<li><a class="el" href="index.html#error-handling">Error handling</a></li>
<li><a class="el" href="index.html#debug-support">Debug support</a></li>
<li><a class="el" href="index.html#future-plans">Future plans</a></li>
Expand Down Expand Up @@ -383,9 +382,11 @@ <h2><a class="anchor" id="autotoc_md21"></a>
<li><a class="el" href="index.html#execution-blocks">Execution blocks</a></li>
<li><a class="el" href="index.html#lua-script-loading-and-execution">LUA script loading and execution</a></li>
</ul>
<p>Sometimes you want to ececute a series of <a class="el" href="structRedis.html" title="Structure that represents a Redis database instance, with one or more RedisClient connections.">Redis</a> command atomically, such that nothing else may alter the database while the set of commands execute, so they may return a coherent state. For example, you want to set or query a collection of related variables so they change together and are reported together. You have two choices. (1) you can execute the <a class="el" href="structRedis.html" title="Structure that represents a Redis database instance, with one or more RedisClient connections.">Redis</a> commands in an execution block, or else (2) load a LUA script onto the <a class="el" href="structRedis.html" title="Structure that represents a Redis database instance, with one or more RedisClient connections.">Redis</a> server and call it with some parameters (possibly many times over).</p>
<p><a class="anchor" id="execution-blocks"></a> </p>
<h3><a class="anchor" id="autotoc_md22"></a>
Execution blocks</h3>
<p>Execution blocks offer a fairly simple way of bunching</p>
<div class="fragment"><div class="line"><a class="code hl_struct" href="structRedis.html">Redis</a> *redis = ...;</div>
<div class="line"><a class="code hl_struct" href="structRESP.html">RESP</a> *result;</div>
<div class="line"> </div>
Expand Down Expand Up @@ -419,9 +420,12 @@ <h3><a class="anchor" id="autotoc_md22"></a>
<div class="ttc" id="aredisx-io_8c_html_a6fed65f9413569c771d5165a0194477a"><div class="ttname"><a href="redisx-io_8c.html#a6fed65f9413569c771d5165a0194477a">redisxExecBlockAsync</a></div><div class="ttdeci">RESP * redisxExecBlockAsync(RedisClient *cl)</div><div class="ttdef"><b>Definition</b> redisx-io.c:365</div></div>
<div class="ttc" id="aredisx_8h_html_a5349b7340813fbd1e32d04ed650bc3d9a414a7601469647f3a8827a3908c2c358"><div class="ttname"><a href="redisx_8h.html#a5349b7340813fbd1e32d04ed650bc3d9a414a7601469647f3a8827a3908c2c358">INTERACTIVE_CHANNEL</a></div><div class="ttdeci">@ INTERACTIVE_CHANNEL</div><div class="ttdoc">Redis channel number for interactive queries.</div><div class="ttdef"><b>Definition</b> redisx.h:103</div></div>
<div class="ttc" id="astructRedisClient_html"><div class="ttname"><a href="structRedisClient.html">RedisClient</a></div><div class="ttdoc">Structure that represents a single Redis client connection instance.</div><div class="ttdef"><b>Definition</b> redisx.h:139</div></div>
</div><!-- fragment --><p><a class="anchor" id="lua-script-loading-and-execution"></a> </p>
</div><!-- fragment --><p>If at any point things don't go accoring to plan in the middle of the block, you can call <code>redisAbortBlockAsync()</code> to abort and discard all prior commands submitted in the execution block already.</p>
<p><a class="anchor" id="lua-script-loading-and-execution"></a> </p>
<h3><a class="anchor" id="autotoc_md23"></a>
LUA script loading and execution</h3>
<p>LUA scripting offers a more capable version of executing more complex routines on the <a class="el" href="structRedis.html" title="Structure that represents a Redis database instance, with one or more RedisClient connections.">Redis</a> server. LUA is a scripting language akin to python, and allows you to add extra logic, string manipulation etc to your <a class="el" href="structRedis.html" title="Structure that represents a Redis database instance, with one or more RedisClient connections.">Redis</a> queries. Best of all, once you upload the script to the server, it can reduce network traffic significantly by not having to repeatedly submit the same set of <a class="el" href="structRedis.html" title="Structure that represents a Redis database instance, with one or more RedisClient connections.">Redis</a> commands every single time. LUA scipts also get executed very efficiently on the server, and produce only the result you want/need.</p>
<p>Assuming you have prepared your LUA script, you can upload it to the <a class="el" href="structRedis.html" title="Structure that represents a Redis database instance, with one or more RedisClient connections.">Redis</a> server as:</p>
<div class="fragment"><div class="line"><a class="code hl_struct" href="structRedis.html">Redis</a> *redis = ...</div>
<div class="line">char *script = ... <span class="comment">// The LUA script as a 0-terminated string.</span></div>
<div class="line"><span class="keywordtype">char</span> *scriptSHA1 = NULL; <span class="comment">// We&#39;ll store the SHA1 sum of the script here</span></div>
Expand All @@ -432,7 +436,8 @@ <h3><a class="anchor" id="autotoc_md23"></a>
<div class="line"> <span class="comment">// Oops, something went wrong...</span></div>
<div class="line"> ...</div>
<div class="line">}</div>
</div><!-- fragment --><div class="fragment"><div class="line"><a class="code hl_struct" href="structRedis.html">Redis</a> *redis = ...</div>
</div><!-- fragment --><p><a class="el" href="structRedis.html" title="Structure that represents a Redis database instance, with one or more RedisClient connections.">Redis</a> will refer to the script by its SHA1 sum, so it's important keep a record of it. You'll call the script with its SHA1 sum, a set of redis keys the script may use, and a set of other parameters it might need.</p>
<div class="fragment"><div class="line"><a class="code hl_struct" href="structRedis.html">Redis</a> *redis = ...</div>
<div class="line">int status;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Execute the script, with one redis key argument (and no parameters)...</span></div>
Expand All @@ -441,6 +446,7 @@ <h3><a class="anchor" id="autotoc_md23"></a>
<div class="line"><span class="comment">// Check status and inspect RESP</span></div>
<div class="line">...</div>
</div><!-- fragment --><p>Clearly, if you have additional <a class="el" href="structRedis.html" title="Structure that represents a Redis database instance, with one or more RedisClient connections.">Redis</a> key arguments and/or parameters to pass to the script, you'll have to use <code><a class="el" href="redisx-io_8c.html#a13ae33bc25ee03621b23541236ef5f82">redisxArrayRequest()</a></code>, instead.</p>
<p>One thing to keep in mind about LUA scripts is that they are not persistent. They are lost each time the <a class="el" href="structRedis.html" title="Structure that represents a Redis database instance, with one or more RedisClient connections.">Redis</a> server is restarted.</p>
<hr />
<p><a class="anchor" id="accessing-key-value-data"></a> </p>
<h2><a class="anchor" id="autotoc_md25"></a>
Expand Down Expand Up @@ -582,12 +588,8 @@ <h3><a class="anchor" id="autotoc_md31"></a>
</div><!-- fragment --><p>Now, we are capturing and processing all messages published to channels whose name begins with <code>"event:"</code>, using our custom <code>my_event_processor</code> function.</p>
<p>To end the subscription, we trace back the same steps by calling <code><a class="el" href="redisx-sub_8c.html#accafa9bf1ced851cc2e95c2d9fa1e9f8">redisxUnsubscribe()</a></code> to stop receiving further messages to the subscription channel or pattern, and by removing the <code>my_event_procesor</code> subscriber function as appropriate (provided no other subscription needs it) via <code>redisxRemoveSubscriber()</code>.</p>
<hr />
<p><a class="anchor" id="implementing-further-redis-commands"></a> </p>
<h2><a class="anchor" id="autotoc_md33"></a>
Implementing further Redis commands</h2>
<hr />
<p><a class="anchor" id="error-handling"></a> </p>
<h2><a class="anchor" id="autotoc_md35"></a>
<h2><a class="anchor" id="autotoc_md33"></a>
Error handling</h2>
<p>Error handling of RedisX is an extension of that of <b>xchange</b>, with further error codes defined in <code><a class="el" href="redisx_8h.html">redisx.h</a></code>. The RedisX functions that return an error status (either directly, or into the integer designated by a pointer argument), can be inspected by <code><a class="el" href="redisx_8c.html#a38f3de77ad5a48d37b302bce2e3cd25b">redisxErrorDescription()</a></code>, e.g.:</p>
<div class="fragment"><div class="line"><a class="code hl_struct" href="structRedis.html">Redis</a> *redis ...</div>
Expand All @@ -599,13 +601,13 @@ <h2><a class="anchor" id="autotoc_md35"></a>
<div class="line">}</div>
</div><!-- fragment --><hr />
<p><a class="anchor" id="debug-support"></a> </p>
<h2><a class="anchor" id="autotoc_md37"></a>
<h2><a class="anchor" id="autotoc_md35"></a>
Debug support</h2>
<p>The <b>xchange</b> library provides two macros: <code><a class="elRef" href="../../xchange/apidoc/html/xchange_8h.html#a1f038bf7ddb58819805cfc44162cb403">xvprintf()</a></code> and <code><a class="elRef" href="../../xchange/apidoc/html/xchange_8h.html#a2b0edfea798e9e08122f09dba5f189f8">xdprintf()</a></code>, for printing verbose and debug messages to <code>stderr</code>. Both work just like <code>printf()</code>, but they are conditional on verbosity being enabled via <code><a class="el" href="redisx_8c.html#a11454a2359f43b6fd024d25a8148644e">redisxSetVerbose(boolean)</a></code> and the global variable <code>xDebug</code> being <code>TRUE</code> (non-zero), respectively. Applications using <b>RedisX</b> may use these macros to produce their own verbose and/or debugging outputs conditional on the same global settings.</p>
<p>You can also turn debug messages by defining the <code>DEBUG</code> constant for the compiler, e.g. by adding <code>-DDEBUG</code> to <code>CFLAGS</code> prior to calling <code>make</code>.</p>
<hr />
<p><a class="anchor" id="future-plans"></a> </p>
<h2><a class="anchor" id="autotoc_md39"></a>
<h2><a class="anchor" id="autotoc_md37"></a>
Future plans</h2>
<p>Some obvious ways the library could evolve and grow in the not too distant future:</p>
<ul>
Expand Down
7 changes: 3 additions & 4 deletions apidoc/html/navtreedata.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ var NAVTREE =
[ "Broadcasting messages", "index.html#autotoc_md30", null ],
[ "Subscriptions", "index.html#autotoc_md31", null ]
] ],
[ "Implementing further Redis commands", "index.html#autotoc_md33", null ],
[ "Error handling", "index.html#autotoc_md35", null ],
[ "Debug support", "index.html#autotoc_md37", null ],
[ "Future plans", "index.html#autotoc_md39", null ],
[ "Error handling", "index.html#autotoc_md33", null ],
[ "Debug support", "index.html#autotoc_md35", null ],
[ "Future plans", "index.html#autotoc_md37", null ],
[ "[Unreleased]", "../../xchange/apidoc/html/md_CHANGELOG.html#autotoc_md1", null ]
] ],
[ "Contributing to RedisX", "../../xchange/apidoc/html/md_CONTRIBUTING.html", null ],
Expand Down
3 changes: 1 addition & 2 deletions apidoc/html/navtreeindex0.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ var NAVTREEINDEX0 =
"index.html#autotoc_md33":[9],
"index.html#autotoc_md35":[10],
"index.html#autotoc_md37":[11],
"index.html#autotoc_md39":[12],
"index.html#autotoc_md4":[1],
"index.html#autotoc_md6":[2],
"index.html#autotoc_md8":[3],
"md_CHANGELOG.html":[0],
"md_CHANGELOG.html#autotoc_md1":[0,13],
"md_CHANGELOG.html#autotoc_md1":[0,12],
"md_CONTRIBUTING.html":[1],
"pages.html":[],
"redisx-hooks_8c.html":[3,0,1,0],
Expand Down
Loading

0 comments on commit 832d863

Please sign in to comment.