运行时配置
这些函数的行为受 php.ini 中的设置影响。
名字 | 默认 | 可修改范围 | 更新日志 |
---|---|---|---|
memcached.sess_locking | 1 | PHP_INI_ALL | |
memcached.sess_consistent_hash | 0 | PHP_INI_ALL | |
memcached.sess_binary | 0 | PHP_INI_ALL | |
memcached.sess_lock_wait | 150000 | PHP_INI_ALL | |
memcached.sess_prefix | memc.sess.key. | PHP_INI_ALL | |
memcached.sess_number_of_replicas | 0 | PHP_INI_ALL | |
memcached.sess_randomize_replica_read | 0 | PHP_INI_ALL | |
memcached.sess_remove_failed | 0 | PHP_INI_ALL | |
memcached.compression_type | fastlz | PHP_INI_ALL | |
memcached.compression_factor | 1.3 | PHP_INI_ALL | |
memcached.compression_threshold | 2000 | PHP_INI_ALL | |
memcached.serializer | php | PHP_INI_ALL | |
memcached.use_sasl | 0 | PHP_INI_SYSTEM |
这是配置指令的简短说明。
-
memcached.sess_locking
integer -
开启session支持。有效值: On, Off, 默认值 On.
-
memcached.sess_consistent_hash
integer -
Memcached 是否使用一致性哈希保存session。如果为On,session数据保存则使用一致性哈希模式。 使用一致性哈希,可以保证你在增加或删除memcached服务器节点的时候不会导致session大规模的失效。 默认此项是关闭的。
-
memcached.sess_binary
integer -
Memcached session是否使用二进制模式。如果Libmemcached 开启二进制模式。默认值是 Off.
-
memcached.sess_lock_wait
integer -
Session 自旋锁等待时间(微秒)。请小心设置此值。值的类型是整数,当此值被设置为0的时候,lock wait的时间将会使用系统默认值,Memcached扩展中默认值是150000。
-
memcached.sess_prefix
string -
设置memcached session key的前缀。session前缀最长为219字节长的字符串。默认值是“memc.sess.key.”。
-
memcached.sess_number_of_replicas
integer -
使用memcached写session多少个副本。
-
memcached.sess_randomize_replica_read
integer -
Memcached session 是否随机复制读。默认值0
-
memcached.sess_remove_failed
integer -
是否允许自动剔除出故障的memcached服务器。默认值0
-
memcached.compression_type
string -
设置memcached的压缩类型,允许的值为fastlz, zlib。默认值是fastlz(快速无损压缩,性能不错)。
-
memcached.compression_factor
float -
压缩因子. 保存时压缩因子超过设置的极限才会将数据压缩存储。存储压缩条件: plain_len > comp_len * factor。默认是1.3 (节省23%的空间)。
-
memcached.compression_threshold
integer -
压缩阈值。不压缩的序列化值低于此阈值。默认值是2000字节。
-
memcached.serializer
string -
设置缓存对象的默认序列化程序。有效值: php, igbinary, json, json_array.
- json
-
标准的PHP JSON编码。此序列化程序快速而且是压缩后的数据,但是处理UTF-8编码数据时会不完全实现序列化。请查看JSON扩展。
- json_array
-
json序列化,但是反序列化的时候返回数组。
- php
-
PHP标准序列化
- igbinary
-
二进制序列化
如果二进制序列化可用,则优先使用二进制序列化,否则使用php标准序列化。
-
memcached.use_sasl
integer -
链接memcached服务器时启用SASL认证。有效值On, Off。默认值是Off。

User Contributed Notes 3 notes
In case, you are wondering why your sessions are "killed" after 1440 seconds, take a look at session.gc_maxlifetime. It's value is used in memcached expiration field according to memcache protocol rules. Also, do not forget about cookie expiration time
Apparently in version 3.0.3 the default for memcached.sess_binary_protocol in TRUE. Also note the key is memcached.sess_binary_protocol, not memcached.sess.
Setting memcached.sess_binary_protocol to FALSE is required if you want to save the session to memcached through twemproxy.
you can get the list of the possible options for the memcached.ini configuration file here:
https://github.com/php-memcached-dev/php-memcached/blob/master/memcached.ini
备份地址:http://www.lvesu.com/blog/php/memcached.configuration.php