Magento 啟用 Memcached 緩衝的設定方法

來源:互聯網
上載者:User


原生支援使用 Memcached 緩衝,但是需要在設定檔中進行設定。

先不廢話,上代碼(app/etc/local.xml):

<global>
    ...
    <cache>
        <auto_refresh_fast_cache>true</auto_refresh_fast_cache>
        <backend>memcached</backend>
        <backend_options>
            <servers>
                <server>
                    <host>localhost</host>
                    <port>11211</port>
                    <persistent>true</persistent>
                    <weight>1</weight>
                    <timeout>1</timeout>
                    <retry_interval>15</retry_interval>
                </server>
            </servers>
        </backend_options>
    </cache>
    ...
</global>
 

Memcached 最迷人的地方主要在於它的分布式,可以實現均衡負載,緩解瞬時訪問量大的問題。既然是分布式,那麼當然可以使用多個伺服器,其中 servers 節點下邊就可以添加多個 server 節點,以實現多伺服器的配置。

如果在設定 Memcached 之前在後台啟用過緩衝,那麼有可能在開啟 Memcached 後訪問網站會出現錯誤,這是預設的緩衝格式跟 Memcached 不一樣導致的。一般來說只需要把 var/cache 目錄下的檔案清空就可以解決這個問題。

雖然 Memcached 可以一定程度實現提高運行速度(因為它把緩衝暫存到記憶體中),但它的主要功能還是分布式負載平衡。如果網站瞬時訪問量不大,而且使用固態硬碟的話就沒有必要使用 memcached 了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.