Fix error when Memcached::getAllKeys() fails.

Refs #7546
This commit is contained in:
mark_story 2015-10-14 21:56:01 -04:00
parent e0d2c45d9a
commit e8a0726737

View file

@ -273,7 +273,8 @@ class MemcachedEngine extends CacheEngine {
* *
* @param bool $check If true no deletes will occur and instead CakePHP will rely * @param bool $check If true no deletes will occur and instead CakePHP will rely
* on key TTL values. * on key TTL values.
* @return bool True if the cache was successfully cleared, false otherwise * @return bool True if the cache was successfully cleared, false otherwise. Will
* also return false if you are using a binary protocol.
*/ */
public function clear($check) { public function clear($check) {
if ($check) { if ($check) {
@ -281,6 +282,9 @@ class MemcachedEngine extends CacheEngine {
} }
$keys = $this->_Memcached->getAllKeys(); $keys = $this->_Memcached->getAllKeys();
if ($keys === false) {
return false;
}
foreach ($keys as $key) { foreach ($keys as $key) {
if (strpos($key, $this->settings['prefix']) === 0) { if (strpos($key, $this->settings['prefix']) === 0) {