<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Redis on Kenno&#39;s Open Note</title>
    <link>https://blog.khmersite.net/tags/redis/</link>
    <description>Recent content in Redis on Kenno&#39;s Open Note</description>
    <image>
      <title>Kenno&#39;s Open Note</title>
      <url>https://blog.khmersite.net/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</url>
      <link>https://blog.khmersite.net/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</link>
    </image>
    <generator>Hugo -- 0.154.0</generator>
    <language>en</language>
    <lastBuildDate>Wed, 03 Jul 2024 21:46:56 +1000</lastBuildDate>
    <atom:link href="https://blog.khmersite.net/tags/redis/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Delete ElastiCache Redis Cluster Using AWS CLI</title>
      <link>https://blog.khmersite.net/p/delete-elasticache-redis-cluster-using-aws-cli/</link>
      <pubDate>Wed, 03 Jul 2024 21:46:56 +1000</pubDate>
      <guid>https://blog.khmersite.net/p/delete-elasticache-redis-cluster-using-aws-cli/</guid>
      <description>&lt;p&gt;Once upon a time there exist an ElastiCache Redis cluster that I no longer needed. I know that the cluster could be deleted via ElastiCache web console.
However, as a command-line addict as myself, I wanted to use AWS CLI to delete the cluster instead.&lt;/p&gt;
&lt;p&gt;Well, actually this is my first time trying to delete an ElastiCache cluster using the CLI. I&amp;rsquo;m going to try to document how I do this, and what mistakes
I&amp;rsquo;d make a long the way. The cluster name is called &amp;lsquo;my-test-cluster&amp;rsquo;. Let&amp;rsquo;s get started&lt;/p&gt;</description>
    </item>
    <item>
      <title>Connect to a Redis cluster with Python</title>
      <link>https://blog.khmersite.net/p/connect-to-redis-cluster-with-python/</link>
      <pubDate>Wed, 03 Apr 2024 22:27:50 +1100</pubDate>
      <guid>https://blog.khmersite.net/p/connect-to-redis-cluster-with-python/</guid>
      <description>&lt;p&gt;To connect to a Redis server with Python, one can use &lt;code&gt;python3-redis&lt;/code&gt; module.&lt;/p&gt;
&lt;p&gt;First verify that &lt;code&gt;python3-redis&lt;/code&gt; module is installed. I&amp;rsquo;m showing the package name in Fedora 39, if you use a different distro, then check for the relevant package name.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$ rpm -q python3-redis
python3-redis-4.3.3-1.el9.noarch
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Here is the sample code to connect to a non-cluster Redis server:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; redis
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Connect to Redis&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;r &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; redis&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;Redis(host&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;10.97.147.175&amp;#39;&lt;/span&gt;, port&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;6379&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Set a key-value pair&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;r&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;set(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;my_key&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Hello, Redis!&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Get the value of the key&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;value &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; r&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;get(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;my_key&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;print(value&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;decode(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;utf-8&amp;#39;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you want to connect to a Redis cluster (that has both master and replicas), use this version instead:&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to Run Redis in Podman Container</title>
      <link>https://blog.khmersite.net/p/how-to-run-redis-in-podman-container/</link>
      <pubDate>Wed, 22 Feb 2023 23:30:49 +1100</pubDate>
      <guid>https://blog.khmersite.net/p/how-to-run-redis-in-podman-container/</guid>
      <description>&lt;p&gt;This is just a quick note on how to run Redis as a container using Podman on Ubuntu 22.04 (i.e. there will be no mention about SELinux.)&lt;/p&gt;
&lt;h3 id=&#34;create-a-persistent-volume-for-the-redis-container&#34;&gt;Create a persistent volume for the Redis container&lt;/h3&gt;
&lt;p&gt;I like storing all data/volume for containers under &lt;code&gt;/srv/data&lt;/code&gt;. So I&amp;rsquo;ll create a sub-directory called &lt;code&gt;redis-data&lt;/code&gt; under the same location.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# mkdir -p /srv/data/redis-data
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;pull-the-redis-image&#34;&gt;Pull the Redis image&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# podman pull docker.io/redis
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;create-and-run-the-redis-container&#34;&gt;Create and run the Redis container&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;# podman run -d --name redis_server \
    -v /srv/data/redis-data:/var/redis/data \
    -p 6379:6379 redis
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;create-systemd-service-for-the-redis-container&#34;&gt;Create systemd service for the Redis container&lt;/h3&gt;
&lt;p&gt;I like creating a systemd service to enable/start the container.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
