<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Redis Tutorial &#8211; FoxDevelop</title>
	<atom:link href="https://www.foxdevelop.com/category/c-en/c-library/redis-tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.foxdevelop.com</link>
	<description>Independent Software Developer Studio</description>
	<lastBuildDate>Fri, 14 Aug 2026 09:45:09 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>

<image>
	<url>https://www.foxdevelop.com/wp-content/uploads/2026/05/fox-svgrepo-com-1.png</url>
	<title>Redis Tutorial &#8211; FoxDevelop</title>
	<link>https://www.foxdevelop.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Write value</title>
		<link>https://www.foxdevelop.com/2026/08/14/write-value/</link>
					<comments>https://www.foxdevelop.com/2026/08/14/write-value/#respond</comments>
		
		<dc:creator><![CDATA[jack]]></dc:creator>
		<pubDate>Fri, 14 Aug 2026 09:45:08 +0000</pubDate>
				<category><![CDATA[Redis Tutorial]]></category>
		<guid isPermaLink="false">https://www.foxdevelop.com/?p=8605</guid>

					<description><![CDATA[StackExchange.Redis Generic Set / Get for write‑and‑read operations Required namespaces The example below uses Set, accepts a key, byte array, and expiration duration. Notes The earlier WinForms sample used hard‑coded ...]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">StackExchange.Redis Generic Set / Get for write‑and‑read operations</p>



<ol class="wp-block-list">
<li>Underlying call: <code>IDatabase.StringSet()</code> to write Redis string‑type data</li>



<li><strong>Serialization logic</strong>: arbitrary object → JSON string → UTF8 byte array stored into Redis</li>



<li><strong>Deserialization logic</strong>: read byte array → JSON string → target generic object</li>



<li>Return value: <code>true</code> = success, <code>false</code> = failure</li>
</ol>



<p class="wp-block-paragraph">Required namespaces</p>


<pre class="wp-block-code"><span><code class="hljs language-css"><span class="hljs-selector-tag">using</span> <span class="hljs-selector-tag">StackExchange</span><span class="hljs-selector-class">.Redis</span>;
<span class="hljs-selector-tag">using</span> <span class="hljs-selector-tag">Newtonsoft</span><span class="hljs-selector-class">.Json</span>;
<span class="hljs-selector-tag">using</span> <span class="hljs-selector-tag">System</span><span class="hljs-selector-class">.Text</span>;</code></span></pre>


<p class="wp-block-paragraph">The example below uses Set, accepts a key, byte array, and expiration duration.</p>


<pre class="wp-block-code"><span><code class="hljs language-php"><span class="hljs-comment">/// &lt;summary&gt;</span>
<span class="hljs-comment">/// Write cache entry to Redis</span>
<span class="hljs-comment">/// &lt;/summary&gt;</span>
<span class="hljs-comment">/// &lt;param name="key"&gt;Cache key&lt;/param&gt;</span>
<span class="hljs-comment">/// &lt;param name="data"&gt;Any object instance&lt;/param&gt;</span>
<span class="hljs-comment">/// &lt;param name="cacheTime"&gt;Expiration time 【minutes】&lt;/param&gt;</span>
<span class="hljs-comment">/// &lt;returns&gt;true for success / false for failure&lt;/returns&gt;</span>
<span class="hljs-keyword">private</span> bool Set(string key, object data, int cacheTime)
{
    <span class="hljs-keyword">if</span> (data == <span class="hljs-keyword">null</span>)
    {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">false</span>;
    }
    byte&#91;] entryBytes = Serialize(data);
    TimeSpan expiresIn = TimeSpan.FromMinutes(cacheTime);
    <span class="hljs-keyword">return</span> db.StringSet(key, entryBytes, expiresIn);
}

<span class="hljs-comment">/// &lt;summary&gt;</span>
<span class="hljs-comment">/// Object serialization: object → byte&#91;]</span>
<span class="hljs-comment">/// &lt;/summary&gt;</span>
<span class="hljs-keyword">private</span> byte&#91;] Serialize(object data)
{
    string json = JsonConvert.SerializeObject(data);
    <span class="hljs-keyword">return</span> Encoding.UTF8.GetBytes(json);
}

<span class="hljs-comment">/// &lt;summary&gt;</span>
<span class="hljs-comment">/// Read cached value by key</span>
<span class="hljs-comment">/// &lt;/summary&gt;</span>
<span class="hljs-comment">/// &lt;typeparam name="T"&gt;Target object type&lt;/typeparam&gt;</span>
<span class="hljs-comment">/// &lt;param name="key"&gt;Cache key&lt;/param&gt;</span>
<span class="hljs-comment">/// &lt;returns&gt;default(T) if key does not exist&lt;/returns&gt;</span>
<span class="hljs-keyword">public</span> T Get&lt;T&gt;(string key)
{
    RedisValue rValue = db.StringGet(key);
    <span class="hljs-keyword">if</span> (!rValue.HasValue)
    {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">default</span>(T);
    }
    T result = Deserialize&lt;T&gt;(rValue);
    <span class="hljs-keyword">return</span> result;
}

<span class="hljs-comment">/// &lt;summary&gt;</span>
<span class="hljs-comment">/// Deserialization: byte&#91;] → T object</span>
<span class="hljs-comment">/// &lt;/summary&gt;</span>
<span class="hljs-keyword">private</span> T Deserialize&lt;T&gt;(byte&#91;] serializedObject)
{
    <span class="hljs-keyword">if</span> (serializedObject == <span class="hljs-keyword">null</span>)
    {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">default</span>(T);
    }
    string json = Encoding.UTF8.GetString(serializedObject);
    <span class="hljs-keyword">return</span> JsonConvert.DeserializeObject&lt;T&gt;(json);
}</code></span></pre>


<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading">Notes</h4>



<ol class="wp-block-list">
<li><strong>Time unit</strong><br>In code <code>TimeSpan.FromMinutes(cacheTime)</code> means <strong>input value represents 【minutes】</strong><br>If you call <code>Set(key,val,1000)</code> from your form, cache will expire after <strong>1000 minutes</strong>, NOT seconds!</li>
</ol>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">The earlier WinForms sample used hard‑coded <code>1000</code>, this is a common pitfall.<br>If you need to pass <strong>seconds</strong>, replace with <code>TimeSpan.FromSeconds(cacheTime)</code></p>
</blockquote>



<ol start="2" class="wp-block-list">
<li><strong>Dependencies installation</strong><br>Install both NuGet packages:</li>
</ol>



<ul class="wp-block-list">
<li><code>StackExchange.Redis</code></li>



<li><code>Newtonsoft.Json</code></li>
</ul>



<ol start="2" class="wp-block-list">
<li>Data storage format<br>All objects are serialized to JSON binary and stored inside Redis; values viewed in Redis client are standard JSON text.</li>



<li><code>RedisValue</code> compatibility<br><code>db.StringGet(key)</code> returns <code>RedisValue</code>, it supports implicit conversion to <code>byte[]</code> and can be passed directly into <code>Deserialize&lt;T&gt;</code>.</li>



<li>Thread‑safety suggestion<br><code>IConnectionMultiplexer</code> should be global singleton. Do not create new connection on every Redis read‑write.</li>
</ol>



<h4 class="wp-block-heading">Usage example</h4>


<pre class="wp-block-code"><span><code class="hljs language-javascript"><span class="hljs-comment">// Write entry (expire after 30 minutes)</span>
bool ok = <span class="hljs-built_in">Set</span>(<span class="hljs-string">"user:1001"</span>, <span class="hljs-keyword">new</span> {Id = <span class="hljs-number">1001</span>, Name = <span class="hljs-string">"test"</span>}, <span class="hljs-number">30</span>);

<span class="hljs-comment">// Read value</span>
<span class="hljs-keyword">var</span> user = Get&lt;dynamic&gt;(<span class="hljs-string">"user:1001"</span>);

<span class="hljs-comment">// Read model entity example</span>
<span class="hljs-comment">// var model = Get&lt;UserInfo&gt;("user:1001");</span></code></span></pre>


<h4 class="wp-block-heading">Recommendations</h4>



<p class="wp-block-paragraph">Extract these helper methods together with Redis connection logic into a standalone static helper class <code>RedisHelper.cs</code>. Avoid putting them inside Form code for better separation‑of‑concerns.<br></p>



<p class="wp-block-paragraph">Write value</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.foxdevelop.com/2026/08/14/write-value/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Connect to Redis</title>
		<link>https://www.foxdevelop.com/2026/08/14/connect-to-redis/</link>
					<comments>https://www.foxdevelop.com/2026/08/14/connect-to-redis/#respond</comments>
		
		<dc:creator><![CDATA[jack]]></dc:creator>
		<pubDate>Fri, 14 Aug 2026 09:34:16 +0000</pubDate>
				<category><![CDATA[Redis Tutorial]]></category>
		<guid isPermaLink="false">https://www.foxdevelop.com/?p=8588</guid>

					<description><![CDATA[This lesson demonstrates Redis operations inside WinForms. The logic applies to other project types; WinForms is used only for demonstration purposes. After you install Redis, it runs as an independent ...]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">This lesson demonstrates Redis operations inside WinForms. The logic applies to other project types; WinForms is used only for demonstration purposes.</p>



<p class="wp-block-paragraph">After you install Redis, it runs as an independent background service. To access it from C# WinForms, you establish a connection much like connecting to a regular database.</p>



<p class="wp-block-paragraph">The connection‑string configuration shown below is placed inside App.config</p>



<h4 class="wp-block-heading">1. App.config Configuration</h4>


<pre class="wp-block-code"><span><code class="hljs language-xml"><span class="hljs-meta">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">configuration</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">connectionStrings</span>&gt;</span>
    <span class="hljs-comment">&lt;!-- Redis connection string --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">add</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"RedisConnectionString"</span> <span class="hljs-attr">connectionString</span>=<span class="hljs-string">"127.0.0.1:6379"</span>/&gt;</span>
    <span class="hljs-comment">&lt;!-- Short form: connectionString="localhost" uses default port 6379 --&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">connectionStrings</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">startup</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">supportedRuntime</span> <span class="hljs-attr">version</span>=<span class="hljs-string">"v4.0"</span> <span class="hljs-attr">sku</span>=<span class="hljs-string">".NETFramework,Version=v4.5"</span> /&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">startup</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">configuration</span>&gt;</span></code></span></pre>


<p class="wp-block-paragraph">Connection string explanation</p>



<ul class="wp-block-list">
<li><code>localhost</code> / <code>127.0.0.1</code>：Local Redis service</li>



<li>Default port <strong>6379</strong>；Format for non‑default port：<code>127.0.0.1:6380</code></li>



<li>If Redis is password‑protected：<code>127.0.0.1:6379,password=yourpassword</code></li>
</ul>



<h4 class="wp-block-heading">2. Core Code in Form1.cs</h4>



<p class="wp-block-paragraph">Required NuGet package</p>



<p class="wp-block-paragraph"><code>StackExchange.Redis</code></p>



<p class="wp-block-paragraph">Required namespaces</p>


<pre class="wp-block-code"><span><code class="hljs language-cs"><span class="hljs-keyword">using</span> StackExchange.Redis;
<span class="hljs-keyword">using</span> System.Configuration;</code></span></pre>

<pre class="wp-block-code"><span><code class="hljs language-cs"><span class="hljs-keyword">public</span> <span class="hljs-keyword">partial</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Form1</span> : <span class="hljs-title">Form</span>
{
    <span class="hljs-comment">// Redis database operation object</span>
    <span class="hljs-keyword">private</span> IDatabase db;
    <span class="hljs-comment">// Read connection string from config file</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">string</span> ConnectionString = ConfigurationManager.ConnectionStrings&#91;<span class="hljs-string">"RedisConnectionString"</span>].ConnectionString;
    <span class="hljs-comment">// Multiplexed connection (official recommended singleton, volatile for thread‑safety)</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">volatile</span> IConnectionMultiplexer connection;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Form1</span>(<span class="hljs-params"></span>)</span>
    {
        InitializeComponent();
        <span class="hljs-comment">// Establish connection</span>
        connection = ConnectionMultiplexer.Connect(ConnectionString);
        <span class="hljs-comment">// Get default database No.0</span>
        db = connection.GetDatabase();
    }

    <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">button1_Click</span>(<span class="hljs-params"><span class="hljs-keyword">object</span> sender, EventArgs e</span>)</span>
    {
        <span class="hljs-comment">// Set method: write cache (key, value, expiration seconds)</span>
        <span class="hljs-keyword">bool</span> res = Set(<span class="hljs-keyword">this</span>.textBox1.Text, <span class="hljs-keyword">this</span>.textBox2.Text, <span class="hljs-number">1000</span>);
        <span class="hljs-keyword">if</span> (res)
        {
            MessageBox.Show(<span class="hljs-string">"Set succeeded"</span>);
        }
        <span class="hljs-keyword">else</span>
        {
            MessageBox.Show(<span class="hljs-string">"Set failed"</span>);
        }
    }

    <span class="hljs-comment"><span class="hljs-doctag">///</span> <span class="hljs-doctag">&lt;summary&gt;</span></span>
    <span class="hljs-comment"><span class="hljs-doctag">///</span> Simple wrapper for writing Redis string key‑value pairs</span>
    <span class="hljs-comment"><span class="hljs-doctag">///</span> <span class="hljs-doctag">&lt;/summary&gt;</span></span>
    <span class="hljs-function"><span class="hljs-keyword">bool</span> <span class="hljs-title">Set</span>(<span class="hljs-params"><span class="hljs-keyword">string</span> key, <span class="hljs-keyword">object</span> data, <span class="hljs-keyword">int</span> cacheTime</span>)</span>
    {
        <span class="hljs-keyword">if</span> (<span class="hljs-keyword">string</span>.IsNullOrEmpty(key)) <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
        <span class="hljs-comment">// Set expiration time</span>
        <span class="hljs-keyword">var</span> expire = TimeSpan.FromSeconds(cacheTime);
        <span class="hljs-keyword">return</span> db.StringSet(key, data.ToString(), expire);
    }
}</code></span></pre>


<p class="wp-block-paragraph">Connect to Redis</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.foxdevelop.com/2026/08/14/connect-to-redis/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Demonstrate Redis with WinForms</title>
		<link>https://www.foxdevelop.com/2026/08/14/demonstrate-redis-with-winforms/</link>
					<comments>https://www.foxdevelop.com/2026/08/14/demonstrate-redis-with-winforms/#respond</comments>
		
		<dc:creator><![CDATA[jack]]></dc:creator>
		<pubDate>Fri, 14 Aug 2026 09:29:02 +0000</pubDate>
				<category><![CDATA[Redis Tutorial]]></category>
		<guid isPermaLink="false">https://www.foxdevelop.com/?p=8572</guid>

					<description><![CDATA[This section covers C# WinForms Redis cache wrapper based on StackExchange.Redis Open Visual Studio, create a WinForms project, then install dependency packages via NuGet Install Dependencies Redis Wrapper Methods Demonstrate ...]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">This section covers <strong>C# WinForms Redis cache wrapper based on StackExchange.Redis</strong> </p>



<p class="wp-block-paragraph">Open Visual Studio, create a WinForms project, then install dependency packages via NuGet</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="449" height="151" src="https://www.foxdevelop.com/wp-content/uploads/2026/08/image-21.png" alt="" class="wp-image-7218" srcset="https://www.foxdevelop.com/wp-content/uploads/2026/08/image-21.png 449w, https://www.foxdevelop.com/wp-content/uploads/2026/08/image-21-300x101.png 300w" sizes="(max-width: 449px) 100vw, 449px" /></figure>



<h4 class="wp-block-heading">Install Dependencies</h4>



<ol class="wp-block-list">
<li><strong>StackExchange.Redis</strong><br>The most‑popular open‑source Redis client in the .NET ecosystem for communicating with Redis server.<br>Github Repository：<a href="https://github.com/StackExchange/StackExchange/StackExchange.Redis">https://github.com/StackExchange/StackExchange/StackExchange.Redis</a><br>Redis exposes TCP protocol. In theory you could write raw Socket code, but mature third‑party libraries are almost always used in production development.</li>



<li><strong>Newtonsoft.Json（Json.NET）</strong><br>Handles object serialization: converts arbitrary objects into JSON strings then byte arrays for Redis storage; deserializes data on readback.<br>Must be installed from NuGet. The code <code>JsonConvert.SerializeObject</code> comes from this library.</li>
</ol>



<h4 class="wp-block-heading">Redis Wrapper Methods</h4>


<pre class="wp-block-code"><span><code class="hljs language-php"><span class="hljs-comment">// Write cache: store object with expiration in minutes</span>
<span class="hljs-keyword">private</span> bool Set(string key, object data, int cacheTime)
{
    <span class="hljs-keyword">if</span> (data == <span class="hljs-keyword">null</span>)
    {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">false</span>;
    }
    <span class="hljs-keyword">var</span> entryBytes = Serialize(data);
    <span class="hljs-keyword">var</span> expiresIn = TimeSpan.FromMinutes(cacheTime);
    <span class="hljs-keyword">return</span> db.StringSet(key, entryBytes, expiresIn);
}

<span class="hljs-comment">// Object serialization: entity object → UTF8 byte array</span>
<span class="hljs-keyword">private</span> byte&#91;] Serialize(object data)
{
    <span class="hljs-keyword">var</span> json = JsonConvert.SerializeObject(data);
    <span class="hljs-keyword">return</span> Encoding.UTF8.GetBytes(json);
}</code></span></pre>


<p class="wp-block-paragraph">Demonstrate Redis with WinForms</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.foxdevelop.com/2026/08/14/demonstrate-redis-with-winforms/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Installation</title>
		<link>https://www.foxdevelop.com/2026/08/14/installation-4/</link>
					<comments>https://www.foxdevelop.com/2026/08/14/installation-4/#respond</comments>
		
		<dc:creator><![CDATA[jack]]></dc:creator>
		<pubDate>Fri, 14 Aug 2026 06:53:02 +0000</pubDate>
				<category><![CDATA[Redis Tutorial]]></category>
		<guid isPermaLink="false">https://www.foxdevelop.com/?p=8556</guid>

					<description><![CDATA[Windows Redis 3.2.100 Installation and Startup Download Links Core Files After Extraction File Purpose redis‑server.exe Redis server program redis‑cli.exe Redis command‑line client tool redis.windows.conf Default configuration file redis.windows‑service.conf Dedicated config ...]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Windows Redis 3.2.100 Installation and Startup</p>



<h4 class="wp-block-heading">Download Links</h4>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Currently (2026), the official Redis project only provides installation packages for Linux. The Windows port is archived and maintained by Microsoft (no further updates).</p>



<ol class="wp-block-list">
<li>Official site (Linux version): http://redis.io/download</li>



<li>Windows‑version Github repository: https://github.com/MSOpenTech/redis/tags</li>



<li>Sample release (win‑3.2.100):<br>https://github.com/MicrosoftArchive/redis/releases/tag/win-3.2.100</li>
</ol>
</blockquote>



<h4 class="wp-block-heading">Core Files After Extraction</h4>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>File</th><th>Purpose</th></tr></thead><tbody><tr><td>redis‑server.exe</td><td>Redis server program</td></tr><tr><td>redis‑cli.exe</td><td>Redis command‑line client tool</td></tr><tr><td>redis.windows.conf</td><td>Default configuration file</td></tr><tr><td>redis.windows‑service.conf</td><td>Dedicated config for installing as Windows system service</td></tr><tr><td>redis‑benchmark.exe</td><td>Redis performance benchmark tool</td></tr><tr><td>dump.rdb</td><td>Redis persistent data file</td></tr></tbody></table></figure>



<h4 class="wp-block-heading">Start Redis Server via CMD</h4>



<ol class="wp-block-list">
<li>Open CMD and change directory to your extracted Redis folder</li>
</ol>


<pre class="wp-block-code"><span><code class="hljs language-css"><span class="hljs-selector-tag">cd</span> <span class="hljs-selector-tag">D</span>:\<span class="hljs-selector-tag">Redis</span>\<span class="hljs-selector-tag">Redis-x64-3</span><span class="hljs-selector-class">.2</span><span class="hljs-selector-class">.100</span></code></span></pre>


<ol start="2" class="wp-block-list">
<li>Start command (loads configuration file)</li>
</ol>


<pre class="wp-block-code"><span><code class="hljs language-css"><span class="hljs-selector-tag">redis-server</span> <span class="hljs-selector-tag">redis</span><span class="hljs-selector-class">.windows</span><span class="hljs-selector-class">.conf</span></code></span></pre>


<p class="wp-block-paragraph">Signs of successful startup:</p>



<ul class="wp-block-list">
<li>Running mode: <code>Running in standalone mode</code></li>



<li>Default port: <strong>6379</strong></li>
</ul>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Drawback: When you start this way, <strong>closing the CMD window will stop the Redis service immediately</strong></p>
</blockquote>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading">Install as Windows System Service</h4>



<p class="wp-block-paragraph">Starting from ordinary CMD cannot run in background. You can install Redis as a system service to enable auto‑start on boot.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">We only use temporary startup for course demonstration; this step is for reference only.</p>
</blockquote>



<h4 class="wp-block-heading">Redis Connection and Basic Command Test</h4>



<h5 class="wp-block-heading">1. Client connection command</h5>



<p class="wp-block-paragraph">Open a new CMD window, go to Redis directory and run:</p>


<pre class="wp-block-code"><span><code class="hljs language-css"><span class="hljs-selector-tag">redis-cli</span><span class="hljs-selector-class">.exe</span> <span class="hljs-selector-tag">-h</span> 127<span class="hljs-selector-class">.0</span><span class="hljs-selector-class">.0</span><span class="hljs-selector-class">.1</span> <span class="hljs-selector-tag">-p</span> 6379</code></span></pre>


<ul class="wp-block-list">
<li><code>-h</code>: Specify Redis server IP (you can fill in LAN IP of other machines for remote connection)</li>



<li><code>-p</code>: Specify port number</li>
</ul>



<h5 class="wp-block-heading">2. Basic command demo</h5>


<pre class="wp-block-code"><span><code class="hljs language-php"><span class="hljs-comment"># Set key‑value pair</span>
set key1 value1
<span class="hljs-comment"># Get value by key</span>
get key1

<span class="hljs-comment"># Query non‑existent key returns (nil)</span>
get kkkk

set ddd <span class="hljs-number">123</span>
get ddd</code></span></pre>


<p class="wp-block-paragraph">Rules:</p>



<ul class="wp-block-list">
<li><code>set</code> requires both【key】and【value】parameters. Missing parameters will trigger an error</li>



<li>Querying a non‑existing key returns <code>(nil)</code></li>
</ul>



<h4 class="wp-block-heading">Notes</h4>



<ol class="wp-block-list">
<li>Windows Redis 3.2 is very old. <strong>Do not use Windows‑based Redis in production</strong>. Deployment on Linux is recommended;</li>



<li>To connect remotely, you need to adjust firewall settings and modify config file to allow access from external IP addresses;</li>



<li>The server‑side CMD window must stay open for clients to connect normally.</li>
</ol>



<p class="wp-block-paragraph">Installation</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.foxdevelop.com/2026/08/14/installation-4/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Introduction</title>
		<link>https://www.foxdevelop.com/2026/08/14/introduction-5/</link>
					<comments>https://www.foxdevelop.com/2026/08/14/introduction-5/#respond</comments>
		
		<dc:creator><![CDATA[jack]]></dc:creator>
		<pubDate>Fri, 14 Aug 2026 06:41:05 +0000</pubDate>
				<category><![CDATA[Redis Tutorial]]></category>
		<guid isPermaLink="false">https://www.foxdevelop.com/?p=8540</guid>

					<description><![CDATA[Redis Basic Definition Redis is an open‑source software written in ANSI C, network‑accessible key‑value database / storage system that supports in‑memory storage and data persistence. It provides client APIs for ...]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph"></p>



<h4 class="wp-block-heading">Redis Basic Definition</h4>



<p class="wp-block-paragraph">Redis is an <strong>open‑source software written in ANSI C</strong>, network‑accessible key‑value database / storage system that supports in‑memory storage and data persistence. It provides client APIs for multiple programming languages.</p>



<ol class="wp-block-list">
<li>It belongs to NoSQL non‑relational databases;</li>



<li>Similar to Memcached but with richer features, it makes up for many shortcomings of Memcached;</li>



<li>Commonly used as a supplementary caching solution for relational databases such as MySQL.</li>
</ol>



<h4 class="wp-block-heading">Supported Data Types</h4>



<ul class="wp-block-list">
<li><code>String</code>: String type</li>



<li><code>List</code>: Doubly‑linked list</li>



<li><code>Set</code>: Unordered collection</li>



<li><code>zset(sorted set)</code>: Sorted collection</li>



<li><code>Hash</code>: Hash structure (similar to Map)</li>
</ul>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Memcached only supports string type, which is one of the most typical differences between them.</p>
</blockquote>



<h4 class="wp-block-heading">Features</h4>



<ol class="wp-block-list">
<li><strong>Multi‑language client support</strong><br>Official SDKs are available for Java, C/C++, C#, PHP, JavaScript, Python, Ruby, Perl and many other languages for easy integration.</li>



<li><strong>Master‑slave synchronization</strong><br>Supports master‑slave replication for off‑site data backup and read‑write separation to improve service availability.</li>



<li><strong>High performance</strong><br>Data resides mainly in memory for extremely fast read and write performance, widely used as a distributed cache.</li>



<li><strong>Data persistence</strong><br>In‑memory data can be persisted to disk so data will not be fully lost after restart (Memcached has no persistence by default).</li>
</ol>



<h4 class="wp-block-heading">Background</h4>



<p class="wp-block-paragraph">The early Redis project was funded, developed and maintained by VMware.</p>



<p class="wp-block-paragraph">We will demonstrate Redis usage with a <strong>simple WinForm(C#) Redis client demo</strong>, an introductory sample showing how C# connects to Redis.</p>



<ul class="wp-block-list">
<li>Set key‑value pairs</li>



<li>Get value by key<br></li>
</ul>



<p class="wp-block-paragraph"><strong>Brief comparison: Redis vs Memcached</strong></p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Feature</th><th>Redis</th><th>Memcached</th></tr></thead><tbody><tr><td>Data Types</td><td>5 basic structures</td><td>String only</td></tr><tr><td>Persistence</td><td>Supports RDB/AOF persistence</td><td>No persistence support</td></tr><tr><td>Master‑Slave Replication</td><td>Supported</td><td>No native support</td></tr><tr><td>Memory Eviction</td><td>Multiple eviction policies</td><td>LRU eviction</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">Introduction</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.foxdevelop.com/2026/08/14/introduction-5/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
