運行時配置

這些函數的行為受 php.ini 中的設置影響。

Memcache配置選項
名字 默認 可修改范圍 更新日志
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
memcache.protocol ascii >PHP_INI_ALL Supported since memcache 3.0.0
memcache.redundancy 1 >PHP_INI_ALL Supported since memcache 3.0.0
memcache.session_redundancy 2 >PHP_INI_ALL Supported since memcache 3.0.0
memcache.compress_threshold 20000 >PHP_INI_ALL Supported since memcache 3.0.3
memcache.lock_timeout 15 >PHP_INI_ALL Supported since memcache 3.0.4
有關 PHP_INI_* 樣式的更多詳情與定義,見 配置可被設定范圍。

這是配置指令的簡短說明。

memcache.allow_failover bool

是否在發(fā)生錯誤時(對用戶)透明的轉移到其他服務器。

memcache.max_failover_attempts int

定義在寫入和獲取數據時最多嘗試的服務器次數(即:故障轉移最大嘗試數),僅和 memcache.allow_failover結合使用。

memcache.chunk_size int

數據傳輸塊大小,這個值越小網絡I/O次數越多,如果發(fā)現莫名的速度降低, 可以嘗試將此值調至32768。

memcache.default_port string

在嘗試連接memcache的時候如果沒有單獨指定端口默認使用的TCP端口號。

memcache.hash_strategy string

控制key到服務器的映射(分布式)策略。值 consistent允許服務器增減而不會(大量)導致健的重新映射 (譯注:參見http://tech.idv2.com/2008/07/24/memcached-004/),設置為 standard則使用余數方式進行key的映射。

memcache.hash_function string

控制在key-server映射時使用哪個hash函數crc32 標明使用標準CRC32進行hash,fnv則說明使用FNV-1a。

session.save_handler string

當值為memcache時標記使用memcache作為session處理器。

session.save_path string

定義一個逗號分割的用于session存儲的服務器url列表,例如: "tcp://host1:11211, tcp://host2:11211".

每個url可以包含參數,這些參數于方法Memcache::addServer()的參數相同。比如: "tcp://host1:11211?persistent=1&weight=1&timeout=1&retry_interval=15"

memcache.protocol string

memcache.redundancy int

memcache.session_redundancy int

memcache.compress_threshold int

memcache.lock_timeout int