Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions core/Cache/PeclMemcached.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,8 @@ protected function ensureTriedToConnect()
return $this;

$this->triedConnect = true;
$this->instance = new Memcache();

try {

try {
$this->instance->pconnect($this->host, $this->port, $this->connectTimeout);
} catch (BaseException $e) {
$this->instance->connect($this->host, $this->port, $this->connectTimeout);
}

$this->alive = true;

} catch (BaseException $e) {
// bad luck.
}
$this->connect();

return $this;
}
Expand Down Expand Up @@ -235,4 +222,23 @@ protected function store(
Assert::isUnreachable();
}

protected function connect()
{
$this->instance = new Memcache();

try {

try {
$this->instance->pconnect($this->host, $this->port, $this->connectTimeout);
} catch (BaseException $e) {
$this->instance->connect($this->host, $this->port, $this->connectTimeout);
}

$this->alive = true;

} catch (BaseException $e) {
// bad luck.
}
}
}
?>
39 changes: 16 additions & 23 deletions main/Monitoring/PinbedPeclMemcached.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,6 @@ public static function create(
return new self($host, $port);
}

public function __construct(
$host = Memcached::DEFAULT_HOST,
$port = Memcached::DEFAULT_PORT,
$connectTimeout = PeclMemcached::DEFAULT_TIMEOUT
)
{
$this->host = $host;
$this->port = $port;

if (PinbaClient::isEnabled())
PinbaClient::me()->timerStart(
'pecl_memcached_'.$host.'_'.$port.'_connect',
array('pecl_memcached_connect' => $host.'_'.$port)
);

parent::__construct($host, $port, $connectTimeout);

if (PinbaClient::isEnabled())
PinbaClient::me()->timerStop(
'pecl_memcached_'.$host.'_'.$port.'_connect'
);
}

public function append($key, $data)
{
$this->log(__METHOD__);
Expand Down Expand Up @@ -120,6 +97,22 @@ protected function store(

}

protected function connect()
{
if (PinbaClient::isEnabled())
PinbaClient::me()->timerStart(
'pecl_memcached_'.$this->host.'_'.$this->port.'_connect',
array('pecl_memcached_connect' => $this->host.'_'.$this->port)
);

parent::connect();

if (PinbaClient::isEnabled())
PinbaClient::me()->timerStop(
'pecl_memcached_'.$this->host.'_'.$this->port.'_connect'
);
}

/*void */ private function log($methodName)
{
if (PinbaClient::isEnabled())
Expand Down