php操作memcache的使用測試總結

來源:互聯網
上載者:User
1.簡介

memcache模組是一個高效的守護進程,提供用於記憶體緩衝的過程式程式和物件導向的方便的介面,特別是對於設計動態web程式時減少對資料庫的訪問。

memcache也提供用於通訊對話(session_handler)的處理。

更多Memcache 模組相關資訊可以到 http://www.danga.com/memcached/ 查閱。

 1.1.memcache在php.ini中的配置項列表

memcache在php.ini中的配置項列表
名稱 預設值 是否可變 改變日誌
memcache.allow_failover “1” PHP_INI_ALL Available since memcache 2.0.2.
memcache.max_failover_attempts "20" PHP_INI_ALL Available since memcache 2.1.0.
memcache.chunk_size "8192" PHP_INI_ALL Available since memcache 2.0.2.
memcache.default_port "11211" PHP_INI_ALL Available since memcache 2.0.2.
memcache.hash_strategy "standard" PHP_INI_ALL Available since memcache 2.2.0.
memcache.hash_function "crc32" PHP_INI_ALL Available since memcache 2.2.0.
session.save_handler "files" PHP_INI_ALL Supported since memcache 2.1.2
session.save_path "" PHP_INI_ALL Supported since memcache 2.1.2

有關 PHP_INI_* 常量進一步的細節與定義參見PHP手冊php.ini 配置選項。

1.2.以下是配置項的簡要解釋

memcache.allow_failover Boolean

在錯誤時是否透明的容錯移轉到其他伺服器上處理(註:容錯移轉是動詞)。

memcache.max_failover_attempts integer

定義伺服器的數量類設定和擷取資料,只聯合 memcache.allow_failover 一同使用。
 

memcache.chunk_size integer

資料將會被分成指定大小(chunk_size)的塊來傳輸,這個值(chunk_size)越小,寫操作的請求就越多,如果發現其他的無法解釋的減速,請試著將這個值增大到32768.

memcache.default_port string

當串連memcache伺服器的時候,如果沒有指定連接埠這個預設的tcp連接埠將被用。

memcache.hash_strategy string

控制在映射 key 到伺服器時使用哪種策略。設定這個值一致能使hash 演算法始終如一的使用於伺服器接受添加或者刪除池中變數時將不會被重新對應。設定這個值以標準的結果在舊的策略被使用時。

memcache.hash_function string

控制哪種 hsah 函數被應用於 key映射 到伺服器過程中,預設值“crc32”使用 CRC32 演算法,而“fnv”則表示使用 FNV-1a 演算法。

session.save_handler string

通過設定這個值為memcache來確定使用 memcache 用於通訊對話的處理(session handler)。

session.save_path string

定義用於通話儲存的各伺服器連結的分隔字元號,例如:“tcp://host1:11211, tcp://host2:11211”。

每伺服器個連結可以包含被接受於該伺服器的參數,比較類似使用 Memcache::addServer() 來添加的伺服器,例如:“tcp://host1:11211?persistent=1&weight=1&timeout=1& amp; amp;retry_interval=15”。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.