Added failureCallback, reduced timeouts to 1s

parent b010ed83
...@@ -94,7 +94,7 @@ class MemCache extends Cache ...@@ -94,7 +94,7 @@ class MemCache extends Cache
$cache->addServer($server->host, $server->port, $server->weight); $cache->addServer($server->host, $server->port, $server->weight);
} else { } else {
$cache->addServer($server->host, $server->port, $server->persistent, $cache->addServer($server->host, $server->port, $server->persistent,
$server->weight, $server->timeout, $server->retryInterval, $server->status, null, $server->timemoutms); $server->weight, $server->timeout, $server->retryInterval, $server->status, $server->failureCallback, $server->timemoutms);
} }
} }
} else { } else {
......
...@@ -37,7 +37,7 @@ class MemCacheServer extends \yii\base\Object ...@@ -37,7 +37,7 @@ class MemCacheServer extends \yii\base\Object
/** /**
* @var integer value in seconds which will be used for connecting to the server. This is used by memcache only. * @var integer value in seconds which will be used for connecting to the server. This is used by memcache only.
*/ */
public $timeout = 2; public $timeout = 1;
/** /**
* @var integer how often a failed server will be retried (in seconds). This is used by memcache only. * @var integer how often a failed server will be retried (in seconds). This is used by memcache only.
*/ */
...@@ -47,8 +47,14 @@ class MemCacheServer extends \yii\base\Object ...@@ -47,8 +47,14 @@ class MemCacheServer extends \yii\base\Object
*/ */
public $status = true; public $status = true;
/** /**
* @var integer value in milliseconds which will be used for connecting to the server. * @var \Closure allows the user to specify a callback function to run upon encountering an error.
* Takes precedence over timeout. This is used by memcache only. * The callback is run before failover is attempted. The function takes two parameters,
*/ * the [[host]] and the [[port]] of the failed server.
public $timemoutms = 2000; */
public $failureCallback = null;
/**
* @var integer value in milliseconds which will be used for connecting to the server.
* Takes precedence over [[timeout]]. This is used by memcache only.
*/
public $timemoutms = 1000;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment