<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>hiredis guide (C) on Docs</title>
    <link>https://redis.io/docs/latest/develop/clients/hiredis/</link>
    <description>Recent content in hiredis guide (C) on Docs</description>
    <generator>Hugo</generator>
    <language>en</language>
    <atom:link href="https://redis.io/docs/latest/develop/clients/hiredis/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Connect</title>
      <link>https://redis.io/docs/latest/develop/clients/hiredis/connect/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://redis.io/docs/latest/develop/clients/hiredis/connect/</guid>
      <description>&lt;h2 id=&#34;basic-synchronous-connection&#34; class=&#34;group relative&#34;&gt;&#xA;  Basic synchronous connection&#xA;  &lt;a href=&#34;#basic-synchronous-connection&#34; class=&#34;header-link opacity-0 group-hover:opacity-100 transition-opacity duration-200 ml-1 align-baseline&#34; aria-label=&#34;Link to this section&#34; title=&#34;Copy link to clipboard&#34;&gt;&#xA;    &lt;svg class=&#34;inline-block w-4 h-4 align-baseline&#34; fill=&#34;currentColor&#34; viewBox=&#34;0 0 20 20&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;&#xA;      &lt;path fill-rule=&#34;evenodd&#34; d=&#34;M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z&#34; clip-rule=&#34;evenodd&#34;&gt;&lt;/path&gt;&#xA;    &lt;/svg&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;The example below creates a simple synchronous connection to a local&#xA;Redis server and tests the connection, before closing it with&#xA;&lt;code&gt;redisFree()&lt;/code&gt;. The &lt;code&gt;redisConnect()&lt;/code&gt; function takes just a hostname&#xA;and port as its arguments, and returns a context object.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Issue commands</title>
      <link>https://redis.io/docs/latest/develop/clients/hiredis/issue-commands/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://redis.io/docs/latest/develop/clients/hiredis/issue-commands/</guid>
      <description>&lt;p&gt;Unlike the other &lt;a href=&#34;https://redis.io/docs/latest/develop/clients/&#34;&gt;client libraries&lt;/a&gt;,&#xA;&lt;code&gt;hiredis&lt;/code&gt; doesn&#39;t provide an extensive API to construct the many different&#xA;Redis &lt;a href=&#34;https://redis.io/docs/latest/commands/&#34;&gt;commands&lt;/a&gt;. However, it does provide a lightweight and&#xA;flexible API to help you construct commands and parse their replies from&#xA;your own code.&lt;/p&gt;&#xA;&lt;p&gt;The sections below describe the available functions in&#xA;detail.&lt;/p&gt;&#xA;&lt;h2 id=&#34;construct-synchronous-commands&#34; class=&#34;group relative&#34;&gt;&#xA;  Construct synchronous commands&#xA;  &lt;a href=&#34;#construct-synchronous-commands&#34; class=&#34;header-link opacity-0 group-hover:opacity-100 transition-opacity duration-200 ml-1 align-baseline&#34; aria-label=&#34;Link to this section&#34; title=&#34;Copy link to clipboard&#34;&gt;&#xA;    &lt;svg class=&#34;inline-block w-4 h-4 align-baseline&#34; fill=&#34;currentColor&#34; viewBox=&#34;0 0 20 20&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;&#xA;      &lt;path fill-rule=&#34;evenodd&#34; d=&#34;M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z&#34; clip-rule=&#34;evenodd&#34;&gt;&lt;/path&gt;&#xA;    &lt;/svg&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;Use the &lt;code&gt;redisCommand()&lt;/code&gt; function to send commands to the server:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Handle command replies</title>
      <link>https://redis.io/docs/latest/develop/clients/hiredis/handle-replies/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://redis.io/docs/latest/develop/clients/hiredis/handle-replies/</guid>
      <description>&lt;p&gt;The &lt;code&gt;redisCommand()&lt;/code&gt; and &lt;code&gt;redisCommandArgv()&lt;/code&gt; functions return&#xA;a pointer to a &lt;code&gt;redisReply&lt;/code&gt; object when you issue a command (see&#xA;&lt;a href=&#34;https://redis.io/docs/latest/develop/clients/hiredis/issue-commands/&#34;&gt;Issue commands&lt;/a&gt;&#xA;for more information). This type supports all&#xA;reply formats defined in the&#xA;&lt;a href=&#34;https://redis.io/docs/latest/develop/reference/protocol-spec/#resp-protocol-description&#34;&gt;RESP2 and RESP3&lt;/a&gt;&#xA;protocols, so its content varies greatly between calls.&lt;/p&gt;&#xA;&lt;p&gt;A simple example is the status response returned by the &lt;a href=&#34;https://redis.io/docs/latest/commands/set/&#34;&gt;&lt;code&gt;SET&lt;/code&gt;&lt;/a&gt;&#xA;command. The code below shows how to get this from the &lt;code&gt;redisReply&lt;/code&gt;&#xA;object:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c&#34; data-lang=&#34;c&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;redisReply&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;*&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;reply&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;redisCommand&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;SET greeting Hello&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// Check and free the reply.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;reply&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;!=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;NULL&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nf&#34;&gt;printf&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;Reply: %s&lt;/span&gt;&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;reply&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;str&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nf&#34;&gt;freeReplyObject&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;reply&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;reply&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;NULL&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A null reply indicates an error, so you should always check for this.&#xA;If an error does occur, then the &lt;code&gt;redisContext&lt;/code&gt; object will have a&#xA;non-zero error number in its integer &lt;code&gt;err&lt;/code&gt; field and a textual&#xA;description of the error in its &lt;code&gt;errstr&lt;/code&gt; field.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Pipelines and transactions</title>
      <link>https://redis.io/docs/latest/develop/clients/hiredis/transpipe/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://redis.io/docs/latest/develop/clients/hiredis/transpipe/</guid>
      <description>&lt;p&gt;Redis lets you send a sequence of commands to the server together in a batch.&#xA;There are two types of batch that you can use:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Pipelines&lt;/strong&gt; avoid network and processing overhead by sending several commands&#xA;to the server together in a single communication. The server then sends back&#xA;a single communication with all the responses. See the&#xA;&lt;a href=&#34;https://redis.io/docs/latest/develop/using-commands/pipelining/&#34;&gt;Pipelining&lt;/a&gt; page for more&#xA;information.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Transactions&lt;/strong&gt; guarantee that all the included commands will execute&#xA;to completion without being interrupted by commands from other clients.&#xA;See the &lt;a href=&#34;https://redis.io/docs/latest/develop/using-commands/transactions/&#34;&gt;Transactions&lt;/a&gt;&#xA;page for more information.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;execute-a-pipeline&#34; class=&#34;group relative&#34;&gt;&#xA;  Execute a pipeline&#xA;  &lt;a href=&#34;#execute-a-pipeline&#34; class=&#34;header-link opacity-0 group-hover:opacity-100 transition-opacity duration-200 ml-1 align-baseline&#34; aria-label=&#34;Link to this section&#34; title=&#34;Copy link to clipboard&#34;&gt;&#xA;    &lt;svg class=&#34;inline-block w-4 h-4 align-baseline&#34; fill=&#34;currentColor&#34; viewBox=&#34;0 0 20 20&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;&#xA;      &lt;path fill-rule=&#34;evenodd&#34; d=&#34;M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z&#34; clip-rule=&#34;evenodd&#34;&gt;&lt;/path&gt;&#xA;    &lt;/svg&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/h2&gt;&#xA;&lt;p&gt;There is no command to explicitly start a pipeline with &lt;code&gt;hiredis&lt;/code&gt;,&#xA;but if you issue a command with the &lt;code&gt;redisAppendCommand()&lt;/code&gt; function,&#xA;it will be added to an output buffer without being sent&#xA;immediately to the server.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
