Using the remember helper

parent 3ae3bd92
...@@ -29,15 +29,9 @@ class CachePageDecorator extends BaseCacheDecorator implements PageRepository ...@@ -29,15 +29,9 @@ class CachePageDecorator extends BaseCacheDecorator implements PageRepository
*/ */
public function findHomepage() public function findHomepage()
{ {
return $this->cache return $this->remember(function () {
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.findHomepage",
$this->cacheTime,
function () {
return $this->repository->findHomepage(); return $this->repository->findHomepage();
} });
);
} }
/** /**
...@@ -46,15 +40,9 @@ class CachePageDecorator extends BaseCacheDecorator implements PageRepository ...@@ -46,15 +40,9 @@ class CachePageDecorator extends BaseCacheDecorator implements PageRepository
*/ */
public function countAll() public function countAll()
{ {
return $this->cache return $this->remember(function () {
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.countAll",
$this->cacheTime,
function () {
return $this->repository->countAll(); return $this->repository->countAll();
} });
);
} }
/** /**
...@@ -64,15 +52,9 @@ class CachePageDecorator extends BaseCacheDecorator implements PageRepository ...@@ -64,15 +52,9 @@ class CachePageDecorator extends BaseCacheDecorator implements PageRepository
*/ */
public function findBySlugInLocale($slug, $locale) public function findBySlugInLocale($slug, $locale)
{ {
return $this->cache return $this->remember(function () use($slug, $locale) {
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.findBySlugInLocale.{$slug}.{$locale}",
$this->cacheTime,
function () use ($slug, $locale) {
return $this->repository->findBySlugInLocale($slug, $locale); return $this->repository->findBySlugInLocale($slug, $locale);
} });
);
} }
/** /**
......
...@@ -3,6 +3,8 @@ versions: ...@@ -3,6 +3,8 @@ versions:
"3.4.0@unreleased": "3.4.0@unreleased":
changed: changed:
- Fixed vuejs compatibility - Fixed vuejs compatibility
- Using new <code>remember</code> method in the <code>CachePageDecorator</code> class
- Fixing bug where the current page was not cached as well on the server side pagination
"3.2.0": "3.2.0":
added: added:
- Adding the page status field - Adding the page status field
......
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