Runtime Configuration
The behaviour of these functions is affected by settings in php.ini.
| Name | Default | Changeable | Changelog |
|---|---|---|---|
| memcached.sess_locking | On | INI_ALL | Available as of memcached 0.1.0. |
| memcached.sess_consistent_hash | On | INI_ALL | Available as of memcached 2.1.0. Default value is On as of memcached 3.0.0. |
| memcached.sess_binary | Off | INI_ALL | Available as of memcached 2.0.0. Replaced by memcached.sess_binary_protocol as of memcached 3.0.0. |
| memcached.sess_lock_wait | 150000 | INI_ALL | Available as of memcached 0.1.0. Removed as of memcached 3.0.0. |
| memcached.sess_prefix | memc.sess.key. | INI_ALL | Available as of memcached 0.1.0. |
| memcached.sess_number_of_replicas | 0 | INI_ALL | Available as of memcached 2.1.0. |
| memcached.sess_randomize_replica_read | Off | INI_ALL | Available as of memcached 2.1.0. |
| memcached.sess_remove_failed | On | INI_ALL | Available as of memcached 2.1.0. Replaced by memcached.sess_remove_failed_servers as of memcached 3.0.0. |
| memcached.compression_type | fastlz | INI_ALL | Available as of memcached 0.1.0. |
| memcached.compression_factor | 1.3 | INI_ALL | Available as of memcached 0.1.0. |
| memcached.compression_threshold | 2000 | INI_ALL | Available as of memcached 0.1.0. |
| memcached.serializer | igbinary | INI_ALL | Available as of memcached 0.1.0. |
| memcached.use_sasl | Off | INI_ALL | Available as of memcached 2.2.0. Removed as of memcached 3.0.0. |
| memcached.default_binary_protocol | Off | INI_ALL | Available as of memcached 3.0.0. |
| memcached.default_connect_timeout | 0 | INI_ALL | Available as of memcached 3.0.0. |
| memcached.default_consistent_hash | Off | INI_ALL | Available as of memcached 3.0.0. |
| memcached.sess_binary_protocol | On | INI_ALL | Available as of memcached 3.0.0. Replace memcached.sess_binary. |
| memcached.sess_connect_timeout | 1000 | INI_ALL | Available as of memcached 2.2.0. |
| memcached.sess_consistent_hash_type | ketama | INI_ALL | Available as of memcached 3.1.0. |
| memcached.sess_lock_expire | 0 | INI_ALL | Available as of memcached 2.2.0. |
| memcached.sess_lock_retries | 5 | INI_ALL | Available as of memcached 3.0.0. |
| memcached.sess_lock_wait_max | 150 | INI_ALL | Available as of memcached 3.0.0. Default value 150 as of memcached 3.1.0 (previously 2000). |
| memcached.sess_lock_wait_min | 150 | INI_ALL | Available as of memcached 3.0.0. Default value 150 as of memcached 3.1.0 (previously 1000). |
| memcached.sess_persistent | Off | INI_ALL | Available as of memcached 3.0.0. |
| memcached.sess_remove_failed_servers | Off | INI_ALL | Available as of memcached 3.0.0. Replace memcached.sess_remove_failed. |
| memcached.sess_server_failure_limit | 0 | INI_ALL | Available as of memcached 3.0.0. |
| memcached.sess_sasl_password | null | INI_ALL | Available as of memcached 2.2.0. |
| memcached.sess_sasl_username | null | INI_ALL | Available as of memcached 2.2.0. |
| memcached.store_retry_count | 0 | INI_ALL | Available as of memcached 2.2.0. Default value 0 as of memcached 3.2.0 (previously 2). |
Here's a short explanation of the configuration directives.
memcached.sess_lockingboolUse session locking. Valid values:
On,Off, the default isOn.memcached.sess_consistent_hashboolIf set to
On, consistent hashing (libketama) is used for session handling. When consistent hashing is used, one can add or remove cache node(s) without messing up too much with existing keys. Default isOn.memcached.sess_binaryboolUse memcached session binary mode. Libmemcached replicas only work if binary mode is enabled. The default is
Off.memcached.sess_lock_waitintSession spin lock retry wait time in microseconds. Be careful when setting this value. Valid values are integers, where
0is interpreted as the default value. Negative values result in a reduces locking to a try lock. The default is150000.memcached.sess_prefixstringMemcached session key prefix. Valid values are strings less than 219 bytes long. The default value is
memc.sess.key.memcached.sess_number_of_replicasintWrite data to a number of additional memcached servers. This is "poor man's HA" as libmemcached calls it. If this value is positive and
sess_remove_failed_serversis enabled when a memcached server fails the session will continue to be available from a replica. However, if the failed memcache server becomes available again it will read the session from there which could have old data or no data at all. Default is0.memcached.sess_randomize_replica_readboolMemcached session replica read randomize.
memcached.sess_remove_failedintAllow failed memcached server to automatically be removed.
memcached.compression_typestringSet the compression type, valid values are:
fastlz,zlib. The default isfastlz.memcached.compression_factorfloatCompression factor. Store compressed value only if the compression factor (saving) exceeds the set limit. Store compressed if:
plain_len > comp_len * factor. The default value is1.3(23% space saving).memcached.compression_thresholdintThe compression threshold. Do not compress serialized values below this threshold. The default is
2000bytes.memcached.serializerstringSet the default serializer for new memcached objects. Valid values are:
php,igbinary,json,json_array,msgpack.- json
Standard PHP JSON encoding. This serializer is fast and compact but only works on UTF-8 encoded data and does not fully implement serializing. See the JSON extension. Available as of memcached 0.2.0.
- json_array
As
json, but decodes into arrays. Available as of memcached 2.0.0.- php
The standard PHP serializer.
- igbinary
A binary serializer. Available as of memcached 0.1.4.
- msgpack
A cross-language binary serializer. Available as of memcached 2.2.0.
The default is
igbinaryif available, thenmsgpackif available, thenphpotherwise.memcached.use_saslboolUse SASL authentication for connections. Valid values:
On,Off. The default isOff.memcached.default_binary_protocolboolSets the default memcached protocol for new connections. (To configure the memcached protocol for connections used by sessions, use
memcached.sess_binary_protocolinstead.) If set toOn, the memcached binary protocol is used by default. If set toOff, the memcached text protocol is used. Default isOff.memcached.default_connect_timeoutintSets the default memcached connection timeout for new connections. (To configure the memcached connection timeout for sessions, use
memcached.sess_connect_timeoutinstead.) In non-blocking mode this changes the value of the timeout. During socket connection in milliseconds. Specifying-1means an infinite timeout. Specifying0means using the memcached library's default connection timeout. Default is0.memcached.default_consistent_hashboolSets the default for consistent hashing for new connections. (To configure consistent hashing for session connections, use
memcached.sess_consistent_hashinstead.) If set toOn, consistent hashing (libketama) is used for session handling. When consistent hashing is used, one can add or remove cache node(s) without messing up too much with existing keys default isOff.memcached.sess_binary_protocolboolUse the memcached binary protocol for memcached sessions instead of the text protocol. libmemcached replicas only work if the binary mode is enabled. However, certain proxies (such as twemproxy) will only work if the binary protocol is disabled. Default is
Onas of libmemcached 1.0.18. Prior to libmemcached 1.0.18, the default wasOff.Note: In previous versions of php-memcached, this setting was called
memcached.sess_binary.memcached.sess_connect_timeoutintmemcached connect timeout value In non-blocking mode this changes the value of the timeout during socket connection in milliseconds. Specifying
-1means an infinite timeout.memcached.sess_consistent_hash_typestringMemcached session consistent hash type. If set to
ketama, consistent hashing (libketama) is used for session handling. If set toketama_weighted, weighted consistent hashing (libketama) is used for session handling. Default isketama. Prior to php-memcached 3.0, the default wasketama_weighted.memcached.sess_lock_expireintThe time, in seconds, before a lock should release itself. Setting to
0results in the default behaviour, which is to use PHP'smax_execution_time. Default is0.memcached.sess_lock_retriesintThe number of times to retry locking the session lock, not including the first attempt. Default is
5.memcached.sess_lock_wait_maxintThe maximum time, in milliseconds, to wait between session lock attempts. The default is
150.memcached.sess_lock_wait_minintThe minimum time, in milliseconds, to wait between session lock attempts. This value is double on each lock retry until
memcached.sess_lock_wait_maxis reached, after which any further retries will takememcached.sess_lock_wait_maxseconds. The default is150.memcached.sess_persistentboolWhether or not to re-use the memcached connections corresponding to the value(s) of
session.save_pathafter the execution of the script ends. Don't use this if certain settings (e.g. SASL settings, sess_binary_protocol) would be overridden between requests. Default isOff.memcached.sess_remove_failed_serversboolAllow failed memcached server to automatically be removed. Default is
Off.Note: In previous versions of php-memcached, this setting was called
memcached.sess_remove_failed.memcached.sess_server_failure_limitintSet this value to enable the server be removed after configured number of continuous times connection failure. Default is
0.memcached.sess_sasl_passwordstringSession SASL password. Both username and password need to be set for SASL to be enabled.
memcached.sess_sasl_usernamestringSession SASL username. Both username and password need to be set for SASL to be enabled.
memcached.store_retry_countintThe amount of retries for failed store commands. This mechanism allows transparent fail-over to secondary servers when set/increment/decrement/setMulti operations fail on the desired server in a multi-server environment. The default is
2.