Новости | Документация | Download | Webboard | FAQ | Поиск | Контакты


Memcache::setServerParams

(PECL memcache >= 2.1.0)

Memcache::setServerParamsChanges server parameters and status at runtime

Описание

bool Memcache::setServerParams ( string $host [, int $port [, int $timeout [, int $retry_interval [, bool $status [, callback $failure_callback ]]]]] )

Memcache::setServerParams() changes server parameters at runtime. You can also use the memcache_set_server_params() function.

Замечание: This function has been added to Memcache version 2.1.0.

Список параметров

host

Point to the host where memcached is listening for connections.

port

Point to the port where memcached is listening for connections. This parameter is optional and its default value is 11211.

timeout

Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow.

retry_interval

Controls how often a failed server will be retried, the default value is 15 seconds. Setting this parameter to -1 disables automatic retry. Neither this nor the persistent parameter has any effect when the extension is loaded dynamically via dl().

status

Controls if the server should be flagged as online. Setting this parameter to FALSE and retry_interval to -1 allows a failed server to be kept in the pool so as not to affect the key distribution algoritm. Requests for this server will then failover or fail immediately depending on the memcache.allow_failover setting. Default to TRUE, meaning the server should be considered online.

failure_callback

Allows the user to specify a callback function to run upon encountering an error. The callback is run before failover is attempted. The function takes two parameters, the hostname and port of the failed server.

Возвращаемые значения

Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.

Примеры

Пример #1 Memcache::setServerParams() example

<?php

function _callback_memcache_failure($host$port) {
    print 
"memcache '$host:$port' failed";
}

/* OO API */

$memcache = new Memcache;

// Add the server in offline mode
$memcache->addServer('memcache_host'11211false11, -1false);

// Bring the server back online
$memcache->setServerParams('memcache_host'11211115true'_callback_memcache_failure');

/* procedural API */

$memcache_obj memcache_connect('memcache_host'11211);
memcache_set_server_params($memcache_obj'memcache_host'11211115true'_callback_memcache_failure');

?>

Смотрите также






  Copyright Apache.ru © 1999-2017, All Rights Reserved Разработка сайта: Inside.ru  
  РЕКЛАМА НА САЙТЕ: |