<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:media="http://search.yahoo.com/mrss/"
	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>wordpess &#8211; 馬修 IT</title>
	<atom:link href="https://blog.ocam.live/archives/tag/wordpess/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.ocam.live</link>
	<description>生活中所接觸各種電腦及網路問題與懷舊模擬器的專業問題解決與新資訊介紹的網站</description>
	<lastBuildDate>Tue, 15 Apr 2025 05:59:15 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://blog.ocam.live/wp-content/uploads/2025/03/cropped-logo-1-300x300.png</url>
	<title>wordpess &#8211; 馬修 IT</title>
	<link>https://blog.ocam.live</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>WordPress Redis Object Cache 外掛設定不同 Database 的方式</title>
		<link>https://blog.ocam.live/archives/3477</link>
		
		<dc:creator><![CDATA[blog.ocam.live]]></dc:creator>
		<pubDate>Mon, 14 Apr 2025 08:48:18 +0000</pubDate>
				<category><![CDATA[IT 日常]]></category>
		<category><![CDATA[程式設言]]></category>
		<category><![CDATA[wordpess]]></category>
		<category><![CDATA[外掛]]></category>
		<guid isPermaLink="false">https://blog.ocam.live/?p=3477</guid>

					<description><![CDATA[為什麼要使用 Redis Object Cache 答案是速度，使用這個快取外掛會把常用到的資料存放到記憶體裡 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-z7ow421" id="為什麼要使用-redis-object-cache" data-block-id="z7ow421"><style>.stk-z7ow421 .stk-block-heading__text{text-shadow:none !important;}</style><h2 class="stk-block-heading__text">為什麼要使用 Redis Object Cache</h2></div>



<p class="wp-block-paragraph">答案是速度，使用這個快取外掛會把常用到的資料存放到記憶體裡。由於電腦在存取資料時資料來源是記憶體的存取時間會大幅少於傳統硬碟或 M.2 NVME。這個時間差就是你加速的感覺來源。當然除了電腦的 IO 會減少外 CPU 的使用時間也會相對應的減少。這些減少的電腦資源就會變成效率轉成其它電腦可用的用途。如同時上網人數。</p>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.ocam.live/wp-content/uploads/2025/04/redis-1024x332.png" alt="redis logo" class="wp-image-3486" title="Wordpress Redis Object Cache 外掛設定不同 Database 的方式"></figure>



<div class="wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-1jomie3" id="為什麼要設定不同的-database-，什麼情況下可不用設定，什麼情況需要設定" data-block-id="1jomie3"><h2 class="stk-block-heading__text">為什麼要設定不同的 Database ，什麼情況下可不用設定，什麼情況需要設定</h2></div>



<p class="wp-block-paragraph">一般來說該主機只有一個網站時可不用設定。但多網站時就建議各網站使用自已個別的 Database。除了方便管理之外也可避免掉因為 Redis 的 Database 一樣而產生資料相衝或抓錯不同網站的資料。當一但抓錯資料時你的網站就會出現異常。而且異常的狀況可能非常多樣。所以多個 wordpress 的網站在同一台主機上時通常建議先把各 wordpress 的網站的 database 規劃好並也設定好之後才去裝外掛。</p>



<div class="wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-y4mdvy2" id="redis-object-cache-設定不同的-database-的方式" data-block-id="y4mdvy2"><h2 class="stk-block-heading__text">Redis Object Cache 設定不同的 Database 的方式</h2></div>



<p class="wp-block-paragraph">在 wp-config.php 加上 defined( &#8216;ABSPATH&#8217; ) 上面加上。不可在檔案最尾端加入。在每個需要按裝 Object Cache 外掛的網站都要加上。加上後再去按裝外掛。</p>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.ocam.live/wp-content/uploads/2025/04/redis_wp_config-1024x479.jpg" alt="redis wp config" class="wp-image-3488" title="Wordpress Redis Object Cache 外掛設定不同 Database 的方式"></figure>



<pre class="wp-block-code"><code>define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
define( 'WP_REDIS_DATABASE', 8 );//每個網站都要不一樣，數字可為0至15。如還要更大則需要作其它設定。由於超出本章的範圍就不說明。
define( 'WP_REDIS_MAXTTL', '3600');//資料存在記憶體的時間。單位為秒。
</code></pre>



<div class="wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-ieethug" id="結語" data-block-id="ieethug"><h2 class="stk-block-heading__text">結語</h2></div>



<p class="wp-block-paragraph">這樣就完成了不同的網站設定不同的 Redis Obejct Cache 的設定。當快取的 Hit 愈高時對網站的加速是愈好。另外也必需要提醒一下。如果你的主機網站太多，也建議去 Redis 的設定檔案修改至少這兩項。</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="856" height="313" src="https://blog.ocam.live/wp-content/uploads/2025/04/redis_config.jpg" alt="redis config " class="wp-image-3491" title="Wordpress Redis Object Cache 外掛設定不同 Database 的方式" srcset="https://blog.ocam.live/wp-content/uploads/2025/04/redis_config.jpg 856w, https://blog.ocam.live/wp-content/uploads/2025/04/redis_config-600x219.jpg 600w, https://blog.ocam.live/wp-content/uploads/2025/04/redis_config-768x281.jpg 768w" sizes="(max-width: 856px) 100vw, 856px" /></figure>



<pre class="wp-block-code"><code>maxmemory 200m //請依自已本身租用主機的記憶體容量去設定。
maxmemory-policy allkeys-lru // allkeys-lru 這是我的建議值 。說明檔有 8 項。依自已判斷。
設定完存檔後重啟 Redis Service.</code></pre>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
		
		
		<media:content url="https://blog.ocam.live/wp-content/uploads/2025/04/redis_object_cache_feature_image.jpg" medium="image"></media:content>
            	</item>
	</channel>
</rss>
