There's a currently undocumented variable that is now available (you can see it in php_info()) for session handling:
memcache.session_redundancy
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.
Configuración en tiempo de ejecución
El comportamiento de estas funciones se ve afectado por la configuración de php.ini.
| Nombre | Por defecto | Cambiable | Historial de cambios |
|---|---|---|---|
| memcache.allow_failover | "1" | PHP_INI_ALL | Disponible desde memcache 2.0.2. |
| memcache.max_failover_attempts | "20" | PHP_INI_ALL | Disponible desde memcache 2.1.0. |
| memcache.chunk_size | "8192" | PHP_INI_ALL | Disponible desde memcache 2.0.2. |
| memcache.default_port | "11211" | PHP_INI_ALL | Disponible desde memcache 2.0.2. |
| memcache.hash_strategy | "standard" | PHP_INI_ALL | Disponible desde memcache 2.2.0. |
| memcache.hash_function | "crc32" | PHP_INI_ALL | Disponible desde memcache 2.2.0. |
| session.save_handler | "files" | PHP_INI_ALL | Soportado desde memcache 2.1.2 |
| session.save_path | "" | PHP_INI_ALL | Soportado desde memcache 2.1.2 |
| memcache.protocol | ascii | >PHP_INI_ALL | Soportado desde memcache 3.0.0 |
| memcache.redundancy | 1 | >PHP_INI_ALL | Soportado desde memcache 3.0.0 |
| memcache.session_redundancy | 2 | >PHP_INI_ALL | Soportado desde memcache 3.0.0 |
| memcache.compress_threshold | 20000 | >PHP_INI_ALL | Soportado desde memcache 3.0.3 |
| memcache.lock_timeout | 15 | >PHP_INI_ALL | Soportado desde memcache 3.0.4 |
He aquí una breve explicación de las directivas de configuración.
-
memcache.allow_failoverboolean -
Si se quiere hacer visible los failover en otros servidores en caso de errores.
-
memcache.max_failover_attemptsinteger -
Define el número de servidores a probar cuando se añade y se obtiene información. Úsese solamente en conjunción con memcache.allow_failover.
-
memcache.chunk_sizeinteger -
La información será transferida en bloques del tamaño indicado, definir este valor a un número más pequeño requerirá más escrituras de red. Pruebe de incrementar este valor a 32768 si se nota una lentitud inexplicable.
-
memcache.default_portstring -
El puerto TCP por defecto a usar cuando se conecta a el servidor memcached si no se especifica otro puerto.
-
memcache.hash_strategystring -
Controla el tipo de estrategia a usar cuando se mapean claves en los servidores. Definir este valor como consistent para habilitar hashing consistente que permite a los servidores ser añadidos o eliminados del grupo sin causar que las claves sean remapeadas. Si se define este valor como standard se usará la antigua estrategia.
-
memcache.hash_functionstring -
Controla que tipo de función hash se utiliza cuando se mapean claves a los servidores, crc32 utiliza el stándar hash CRC32 hash mientras que fnv utiliza FNV-1a.
-
session.save_handlerstring -
Si define esta opción como memcache podrá usar memcache como manejador de sesiones.
-
session.save_pathstring -
Define una lista de urls de servidores separados por comas para el almacenamiento de sesiones, por ejemplo "tcp://host1:11211, tcp://host2:11211".
Cada url puede contener parámetros que son aplicados al servidor, son los mismos que en el método Memcache::addServer(). Por ejemplo "tcp://host1:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
-
memcache.protocolstring -
-
memcache.redundancyinteger -
-
memcache.session_redundancyinteger -
-
memcache.compress_thresholdinteger -
-
memcache.lock_timeoutinteger -
Please note that when you specify more than one memcached server, you don't get the session data copied to every memcached server. Info is only copied to the first one. If the 1st server is down, it goes for the second (but the second will lack the info stored into the 1st one)
Since 3.0.0 there are new defaults:
memcache.hash_strategy = consistent
memcache.chunk_size = 32768
