Skip to content

Commit c2184d0

Browse files
committed
Merge pull request #138 from dovg/pinba_memcached_update
Pinba memcached update
1 parent 3c01e13 commit c2184d0

File tree

2 files changed

+36
-37
lines changed

2 files changed

+36
-37
lines changed

core/Cache/PeclMemcached.class.php

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,21 +193,8 @@ protected function ensureTriedToConnect()
193193
return $this;
194194

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

198-
try {
199-
200-
try {
201-
$this->instance->pconnect($this->host, $this->port, $this->connectTimeout);
202-
} catch (BaseException $e) {
203-
$this->instance->connect($this->host, $this->port, $this->connectTimeout);
204-
}
205-
206-
$this->alive = true;
207-
208-
} catch (BaseException $e) {
209-
// bad luck.
210-
}
197+
$this->connect();
211198

212199
return $this;
213200
}
@@ -235,4 +222,23 @@ protected function store(
235222
Assert::isUnreachable();
236223
}
237224

225+
protected function connect()
226+
{
227+
$this->instance = new Memcache();
228+
229+
try {
230+
231+
try {
232+
$this->instance->pconnect($this->host, $this->port, $this->connectTimeout);
233+
} catch (BaseException $e) {
234+
$this->instance->connect($this->host, $this->port, $this->connectTimeout);
235+
}
236+
237+
$this->alive = true;
238+
239+
} catch (BaseException $e) {
240+
// bad luck.
241+
}
242+
}
238243
}
244+
?>

main/Monitoring/PinbedPeclMemcached.class.php

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,6 @@ public static function create(
2929
return new self($host, $port);
3030
}
3131

32-
public function __construct(
33-
$host = Memcached::DEFAULT_HOST,
34-
$port = Memcached::DEFAULT_PORT,
35-
$connectTimeout = PeclMemcached::DEFAULT_TIMEOUT
36-
)
37-
{
38-
$this->host = $host;
39-
$this->port = $port;
40-
41-
if (PinbaClient::isEnabled())
42-
PinbaClient::me()->timerStart(
43-
'pecl_memcached_'.$host.'_'.$port.'_connect',
44-
array('pecl_memcached_connect' => $host.'_'.$port)
45-
);
46-
47-
parent::__construct($host, $port, $connectTimeout);
48-
49-
if (PinbaClient::isEnabled())
50-
PinbaClient::me()->timerStop(
51-
'pecl_memcached_'.$host.'_'.$port.'_connect'
52-
);
53-
}
54-
5532
public function append($key, $data)
5633
{
5734
$this->log(__METHOD__);
@@ -120,6 +97,22 @@ protected function store(
12097

12198
}
12299

100+
protected function connect()
101+
{
102+
if (PinbaClient::isEnabled())
103+
PinbaClient::me()->timerStart(
104+
'pecl_memcached_'.$this->host.'_'.$this->port.'_connect',
105+
array('pecl_memcached_connect' => $this->host.'_'.$this->port)
106+
);
107+
108+
parent::connect();
109+
110+
if (PinbaClient::isEnabled())
111+
PinbaClient::me()->timerStop(
112+
'pecl_memcached_'.$this->host.'_'.$this->port.'_connect'
113+
);
114+
}
115+
123116
/*void */ private function log($methodName)
124117
{
125118
if (PinbaClient::isEnabled())

0 commit comments

Comments
 (0)