Настройка во время выполнения
Поведение этих функций зависит от установок в 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 -
Use session locking. Valid values: On, Off, the default is On.
-
memcached.sess_consistent_hash
integer -
Memcached session consistent hash mode. If set to On, consistent hashing 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. The default is Off.
-
memcached.sess_binary
integer -
Use memcached session binary mode. Libmemcached replicas only work if binary mode is enabled. The default is Off.
-
memcached.sess_lock_wait
integer -
Session spin lock retry wait time in microseconds. Be carefull when setting this value. Valid values are integers, where 0 is interpreted as the default value. Negative values result in a reduces locking to a try lock. The default is 150000.
-
memcached.sess_prefix
string -
Memcached session key prefix. Valid values are strings less than 219 bytes long. The default value is "memc.sess.key."
-
memcached.sess_number_of_replicas
integer -
The memcached session number of replicas.
-
memcached.sess_randomize_replica_read
integer -
Memcached session replica read randomize.
-
memcached.sess_remove_failed
integer -
Allow failed memcached server to automatically be removed.
-
memcached.compression_type
string -
Set the compression type, valid values are: fastlz, zlib. The default is fastlz.
-
memcached.compression_factor
float -
Compression 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 is 1.3 (23% space saving).
-
memcached.compression_threshold
integer -
The compression threshold. Do not compress serialized values below this threshold. The default is 2000 bytes.
-
memcached.serializer
string -
Set the default serializer for new memcached objects. Valid values are: php, igbinary, json, json_array.
- 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.
- json_array
-
As json, but decodes into arrays.
- php
-
The standard PHP serializer.
- igbinary
-
A binary serializer
The default is igbinary if available and php otherwise.
-
memcached.use_sasl
integer -
Use SASL authentication for connections. Valid values: On, Off. The default is Off.
Коментарии
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
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.