<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kohki Chau</title>
    <description>The latest articles on DEV Community by Kohki Chau (@autofun).</description>
    <link>https://dev.to/autofun</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1261027%2Ff1130f33-1cd9-4244-ad79-a0998e4b79b1.jpg</url>
      <title>DEV Community: Kohki Chau</title>
      <link>https://dev.to/autofun</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/autofun"/>
    <language>en</language>
    <item>
      <title>Redis Distributed Lock Tips</title>
      <dc:creator>Kohki Chau</dc:creator>
      <pubDate>Fri, 19 Jan 2024 15:17:20 +0000</pubDate>
      <link>https://dev.to/autofun/redis-distributed-lock-tips-5bca</link>
      <guid>https://dev.to/autofun/redis-distributed-lock-tips-5bca</guid>
      <description>&lt;ol&gt;
&lt;li&gt;The algorithm requires a minimum of &lt;strong&gt;three Redis instances&lt;/strong&gt; to work.&lt;/li&gt;
&lt;li&gt;The client generates a random value called &lt;code&gt;nonce&lt;/code&gt; and tries to acquire a lock on a resource by sending a &lt;code&gt;SET&lt;/code&gt; command to each of the Redis instances with the same &lt;code&gt;resource_name&lt;/code&gt; and &lt;code&gt;nonce&lt;/code&gt; values.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;SET&lt;/code&gt; command should include an &lt;code&gt;EX&lt;/code&gt; parameter to set an expiration time for the lock.&lt;/li&gt;
&lt;li&gt;If the client can acquire the lock on a majority of the Redis instances, it is considered to have acquired the lock.&lt;/li&gt;
&lt;li&gt;If the client fails to acquire the lock on a majority of the Redis instances, it should release the lock on all the instances where it was acquired.&lt;/li&gt;
&lt;li&gt;To release the lock, the client sends a &lt;code&gt;DEL&lt;/code&gt; command to all the Redis instances where it had acquired the lock.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://redis.io/docs/manual/patterns/distributed-locks/"&gt;The Redlock algorithm is designed to provide &lt;strong&gt;mutual exclusion&lt;/strong&gt;, &lt;strong&gt;deadlock-free&lt;/strong&gt; and &lt;strong&gt;fault-tolerant&lt;/strong&gt; guarantees &lt;/a&gt;&lt;/p&gt;

</description>
      <category>redis</category>
      <category>distributedlock</category>
    </item>
  </channel>
</rss>
