diff --git a/lib/Cake/Cache/Engine/MemcacheEngine.php b/lib/Cake/Cache/Engine/MemcacheEngine.php index 150d31c6829..c50b8395957 100644 --- a/lib/Cake/Cache/Engine/MemcacheEngine.php +++ b/lib/Cake/Cache/Engine/MemcacheEngine.php @@ -251,15 +251,13 @@ public function connect($host, $port = 11211) { * @return array **/ public function groups() { - $groups = $this->_compiledGroupNames; - if (empty($groups)) { + if (empty($this->_compiledGroupNames)) { foreach ($this->settings['groups'] as $group) { - $groups[] = $this->settings['prefix'] . $group; + $this->_compiledGroupNames[] = $this->settings['prefix'] . $group; } - $this->_compiledGroupNames = $groups; } - $groups = $this->_Memcache->get($groups); + $groups = $this->_Memcache->get($this->_compiledGroupNames); if (count($groups) !== count($this->settings['groups'])) { foreach ($this->_compiledGroupNames as $group) { if (!isset($groups[$group])) { @@ -271,8 +269,9 @@ public function groups() { } $result = array(); - foreach ($groups as $group => $value) { - $result[] = $group . $value; + $groups = array_values($groups); + foreach ($this->settings['groups'] as $i => $group) { + $result[] = $group . $groups[$i]; } return $result;