Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 911a8d1

Browse files
author
gimpe
committed
added status in config and a small improvement
1 parent 12e263f commit 911a8d1

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

classes/kohana/cache/memcached.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,15 @@ protected function __construct(array $config)
7474
$host = Arr::get($server, 'host');
7575
$port = Arr::get($server, 'port', NULL);
7676
$weight = Arr::get($server, 'weight', NULL);
77+
$status = Arr::get($server, 'status', TRUE);
7778

7879
if (!empty($host))
7980
{
80-
$this->memcached_instance->addServer($host, $port, $weight);
81+
// status can be used by an external healthcheck to mark the memcached instance offline
82+
if ($status === TRUE)
83+
{
84+
$this->memcached_instance->addServer($host, $port, $weight);
85+
}
8186
}
8287
else
8388
{
@@ -108,17 +113,10 @@ public function get($id, $default = NULL)
108113
{
109114
$result = $this->memcached_instance->get($id);
110115

111-
if ($this->memcached_instance->getResultCode() == Memcached::RES_NOTFOUND)
116+
if ($this->memcached_instance->getResultCode() !== Memcached::RES_SUCCESS)
112117
{
113118
$result = $default;
114119
}
115-
else
116-
{
117-
Kohana::$log->add(Log::INFO, ':method: not found :id', array(
118-
':method' => __METHOD__,
119-
':id' => $id,
120-
));
121-
}
122120

123121
return $result;
124122
}

0 commit comments

Comments
 (0)