Using new remember() helper

parent 89508b4a
...@@ -33,15 +33,9 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit ...@@ -33,15 +33,9 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit
*/ */
public function findByName($settingName) public function findByName($settingName)
{ {
return $this->cache return $this->remember(function () use ($settingName) {
->tags([$this->entityName, 'global']) return $this->repository->findByName($settingName);
->remember( });
"{$this->locale}.{$this->entityName}.findByName.{$settingName}",
$this->cacheTime,
function () use ($settingName) {
return $this->repository->findByName($settingName);
}
);
} }
/** /**
...@@ -52,17 +46,9 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit ...@@ -52,17 +46,9 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit
*/ */
public function moduleSettings($modules) public function moduleSettings($modules)
{ {
$moduleList = implode(',', $modules); return $this->remember(function() use ($modules) {
return $this->repository->moduleSettings($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);
}
);
} }
/** /**
...@@ -72,15 +58,9 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit ...@@ -72,15 +58,9 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit
*/ */
public function savedModuleSettings($module) public function savedModuleSettings($module)
{ {
return $this->cache return $this->remember(function() use ($module) {
->tags([$this->entityName, 'global']) return $this->repository->savedModuleSettings($module);
->remember( });
"{$this->locale}.{$this->entityName}.savedModuleSettings.{$module}",
$this->cacheTime,
function () use ($module) {
return $this->repository->savedModuleSettings($module);
}
);
} }
/** /**
...@@ -90,15 +70,9 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit ...@@ -90,15 +70,9 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit
*/ */
public function findByModule($module) public function findByModule($module)
{ {
return $this->cache return $this->remember(function() use ($module) {
->tags([$this->entityName, 'global']) return $this->repository->findByModule($module);
->remember( });
"{$this->locale}.{$this->entityName}.findByModule.{$module}",
$this->cacheTime,
function () use ($module) {
return $this->repository->findByModule($module);
}
);
} }
/** /**
...@@ -108,15 +82,9 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit ...@@ -108,15 +82,9 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit
*/ */
public function get($settingName) public function get($settingName)
{ {
return $this->cache return $this->remember(function() use ($settingName) {
->tags([$this->entityName, 'global']) return $this->repository->get($settingName);
->remember( });
"{$this->locale}.{$this->entityName}.get.{$settingName}",
$this->cacheTime,
function () use ($settingName) {
return $this->repository->get($settingName);
}
);
} }
/** /**
...@@ -126,15 +94,9 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit ...@@ -126,15 +94,9 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit
*/ */
public function translatableModuleSettings($module) public function translatableModuleSettings($module)
{ {
return $this->cache return $this->remember(function() use ($module) {
->tags([$this->entityName, 'global']) return $this->repository->translatableModuleSettings($module);
->remember( });
"{$this->locale}.{$this->entityName}.translatableModuleSettings.{$module}",
$this->cacheTime,
function () use ($module) {
return $this->repository->translatableModuleSettings($module);
}
);
} }
/** /**
...@@ -144,14 +106,8 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit ...@@ -144,14 +106,8 @@ class CacheSettingDecorator extends BaseCacheDecorator implements SettingReposit
*/ */
public function plainModuleSettings($module) public function plainModuleSettings($module)
{ {
return $this->cache return $this->remember(function() use ($module) {
->tags([$this->entityName, 'global']) return $this->repository->plainModuleSettings($module);
->remember( });
"{$this->locale}.{$this->entityName}.plainModuleSettings.{$module}",
$this->cacheTime,
function () use ($module) {
return $this->repository->plainModuleSettings($module);
}
);
} }
} }
...@@ -3,6 +3,7 @@ versions: ...@@ -3,6 +3,7 @@ versions:
"3.4.0@unreleased": "3.4.0@unreleased":
changed: changed:
- Fix settings with falsey values not getting returned - Fix settings with falsey values not getting returned
- Using new <code>remember</code> method in the <code>CacheSettingDecorator</code> class
"3.1.0": "3.1.0":
changed: changed:
- Checking for null value instead of empty for non translatable settings - Checking for null value instead of empty for non translatable settings
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment