Skip to content

Commit

Permalink
Using new remember() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Nov 20, 2017
1 parent 89508b4 commit fee36dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 65 deletions.
86 changes: 21 additions & 65 deletions Modules/Setting/Repositories/Cache/CacheSettingDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,9 @@ public function createOrUpdate($settings)
*/
public function findByName($settingName)
{
return $this->cache
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.findByName.{$settingName}",
$this->cacheTime,
function () use ($settingName) {
return $this->repository->findByName($settingName);
}
);
return $this->remember(function () use ($settingName) {
return $this->repository->findByName($settingName);
});
}

/**
Expand All @@ -52,17 +46,9 @@ function () use ($settingName) {
*/
public function moduleSettings($modules)
{
$moduleList = implode(',', $modules);

return $this->cache
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.moduleSettings.{$moduleList}",
$this->cacheTime,
function () use ($modules) {
return $this->repository->moduleSettings($modules);
}
);
return $this->remember(function() use ($modules) {
return $this->repository->moduleSettings($modules);
});
}

/**
Expand All @@ -72,15 +58,9 @@ function () use ($modules) {
*/
public function savedModuleSettings($module)
{
return $this->cache
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.savedModuleSettings.{$module}",
$this->cacheTime,
function () use ($module) {
return $this->repository->savedModuleSettings($module);
}
);
return $this->remember(function() use ($module) {
return $this->repository->savedModuleSettings($module);
});
}

/**
Expand All @@ -90,15 +70,9 @@ function () use ($module) {
*/
public function findByModule($module)
{
return $this->cache
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.findByModule.{$module}",
$this->cacheTime,
function () use ($module) {
return $this->repository->findByModule($module);
}
);
return $this->remember(function() use ($module) {
return $this->repository->findByModule($module);
});
}

/**
Expand All @@ -108,15 +82,9 @@ function () use ($module) {
*/
public function get($settingName)
{
return $this->cache
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.get.{$settingName}",
$this->cacheTime,
function () use ($settingName) {
return $this->repository->get($settingName);
}
);
return $this->remember(function() use ($settingName) {
return $this->repository->get($settingName);
});
}

/**
Expand All @@ -126,15 +94,9 @@ function () use ($settingName) {
*/
public function translatableModuleSettings($module)
{
return $this->cache
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.translatableModuleSettings.{$module}",
$this->cacheTime,
function () use ($module) {
return $this->repository->translatableModuleSettings($module);
}
);
return $this->remember(function() use ($module) {
return $this->repository->translatableModuleSettings($module);
});
}

/**
Expand All @@ -144,14 +106,8 @@ function () use ($module) {
*/
public function plainModuleSettings($module)
{
return $this->cache
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.plainModuleSettings.{$module}",
$this->cacheTime,
function () use ($module) {
return $this->repository->plainModuleSettings($module);
}
);
return $this->remember(function() use ($module) {
return $this->repository->plainModuleSettings($module);
});
}
}
1 change: 1 addition & 0 deletions Modules/Setting/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ versions:
"3.4.0@unreleased":
changed:
- Fix settings with falsey values not getting returned
- Using new <code>remember</code> method in the <code>CacheSettingDecorator</code> class
"3.1.0":
changed:
- Checking for null value instead of empty for non translatable settings
Expand Down

0 comments on commit fee36dc

Please sign in to comment.