Skip to content

Commit

Permalink
Making sure the Cache::remember() funciton is not hit more than once
Browse files Browse the repository at this point in the history
Getting translators was still calling Cache everytime
  • Loading branch information
lorenzo committed Aug 10, 2014
1 parent 3bcd581 commit 084651d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/I18n/TranslatorRegistry.php
Expand Up @@ -62,7 +62,7 @@ public function get($name, $locale = null) {

if (!isset($this->registry[$name][$locale])) {
$key = "translations.$name.$locale";
return Cache::remember($key, function() use ($name, $locale) {
$translator = Cache::remember($key, function() use ($name, $locale) {
try {
return parent::get($name, $locale);
} catch (\Aura\Intl\Exception $e) {
Expand All @@ -74,6 +74,8 @@ public function get($name, $locale = null) {

return $this->_getFromLoader($name, $locale);
}, '_cake_core_');

return $this->registry[$name][$locale] = $translator;
}

return $this->registry[$name][$locale];
Expand Down

0 comments on commit 084651d

Please sign in to comment.