PHP 8.0.24 Released!


这些函数的行为受 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
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


memcache.max_failover_attempts int

定义在写入和获取数据时最多尝试的服务器次数(即:故障转移最大尝试数),仅和 memcache.allow_failover结合使用。

memcache.chunk_size int

数据传输块大小,这个值越小网络I/O次数越多,如果发现莫名的速度降低, 可以尝试将此值调至32768。

memcache.default_port string


memcache.hash_strategy string

控制key到服务器的映射(分布式)策略。值 consistent允许服务器增减而不会(大量)导致健的重新映射 (译注:参见,设置为 standard则使用余数方式进行key的映射。

memcache.hash_function string

控制在key-server映射时使用哪个hash函数crc32 标明使用标准CRC32进行hash,fnv则说明使用FNV-1a。

session.save_handler string


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

add a note

User Contributed Notes 1 note

kross at escapistmag dot com
12 years ago
There's a currently undocumented variable that is now available (you can see it in php_info()) for session handling:


The default seems to be "2", and it is supposed to influence how many copies of a particular session object that Memcache will store for failover purposes (so with a redundancy of 2, it will store a session on 2 different shards).

This will add slight overhead with extra writes, but overall seems worth it for purposes of failover.
To Top