Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rbbrioso28 committed Apr 13, 2021
2 parents ccebe81 + b4b08e6 commit eeb23c0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,19 @@
// 'my_cache_key' => 60,
]
],
'melisfront_memory_cache' => [
'active' => true, // activate or deactivate Melis Cache for this conf
'adapter' => [
'name' => 'Memory',
'options' => ['ttl' => 0, 'namespace' => 'melisfront'],
],
'plugins' => [
'exception_handler' => ['throw_exceptions' => false],
],
'ttls' => [
// add a specific ttl for a specific cache key (found via regexp]
// 'my_cache_key' => 60,
]
],
]
];
12 changes: 12 additions & 0 deletions src/Service/MelisTranslationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class MelisTranslationService extends MelisGeneralService
*/
public function getTranslationsByLocale($locale = "en_EN")
{
// Retrieve cache version if front mode to avoid multiple calls
$cacheKey = 'getTranslationsByLocale_' . $locale;
$cacheConfig = 'melisfront_memory_cache';
$melisEngineCacheSystem = $this->getServiceManager()->get('MelisEngineCacheSystem');
$results = $melisEngineCacheSystem->getCacheByKey($cacheKey, $cacheConfig, true);
if (!is_null($results))
return $results;

$moduleSvc = $this->getServiceManager()->get('MelisAssetManagerModulesService');
// Event parameters prepare
Expand Down Expand Up @@ -78,11 +85,16 @@ public function getTranslationsByLocale($locale = "en_EN")
}
}
}

// results
$arrayParameters['results'] = $transMessages;

// send event
$arrayParameters = $this->sendEvent('melis_translation_get_trans_by_locale_end', $arrayParameters);

// Save cache key
$melisEngineCacheSystem->setCacheByKey($cacheKey, $cacheConfig, $arrayParameters['results'], true);

return $arrayParameters['results'];

}
Expand Down

0 comments on commit eeb23c0

Please sign in to comment.