Using new remember() helper for menu repositories

parent fee36dc2
...@@ -25,14 +25,8 @@ class CacheMenuDecorator extends BaseCacheDecorator implements MenuRepository ...@@ -25,14 +25,8 @@ class CacheMenuDecorator extends BaseCacheDecorator implements MenuRepository
*/ */
public function allOnline() public function allOnline()
{ {
return $this->cache return $this->remember(function () {
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.allOnline",
$this->cacheTime,
function () {
return $this->repository->allOnline(); return $this->repository->allOnline();
} });
);
} }
} }
...@@ -27,15 +27,9 @@ class CacheMenuItemDecorator extends BaseCacheDecorator implements MenuItemRepos ...@@ -27,15 +27,9 @@ class CacheMenuItemDecorator extends BaseCacheDecorator implements MenuItemRepos
*/ */
public function rootsForMenu($menuId) public function rootsForMenu($menuId)
{ {
return $this->cache return $this->remember(function () use ($menuId) {
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.rootsForMenu.{$menuId}",
$this->cacheTime,
function () use ($menuId) {
return $this->repository->rootsForMenu($menuId); return $this->repository->rootsForMenu($menuId);
} });
);
} }
/** /**
...@@ -45,15 +39,9 @@ class CacheMenuItemDecorator extends BaseCacheDecorator implements MenuItemRepos ...@@ -45,15 +39,9 @@ class CacheMenuItemDecorator extends BaseCacheDecorator implements MenuItemRepos
*/ */
public function getForRoutes() public function getForRoutes()
{ {
return $this->cache return $this->remember(function () {
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.getForRoutes",
$this->cacheTime,
function () {
return $this->repository->getForRoutes(); return $this->repository->getForRoutes();
} });
);
} }
/** /**
...@@ -64,15 +52,9 @@ class CacheMenuItemDecorator extends BaseCacheDecorator implements MenuItemRepos ...@@ -64,15 +52,9 @@ class CacheMenuItemDecorator extends BaseCacheDecorator implements MenuItemRepos
*/ */
public function getRootForMenu($menuId) public function getRootForMenu($menuId)
{ {
return $this->cache return $this->remember(function () use ($menuId) {
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.getRootForMenu.{$menuId}",
$this->cacheTime,
function () use ($menuId) {
return $this->repository->getRootForMenu($menuId); return $this->repository->getRootForMenu($menuId);
} });
);
} }
/** /**
...@@ -83,15 +65,9 @@ class CacheMenuItemDecorator extends BaseCacheDecorator implements MenuItemRepos ...@@ -83,15 +65,9 @@ class CacheMenuItemDecorator extends BaseCacheDecorator implements MenuItemRepos
*/ */
public function getTreeForMenu($menuId) public function getTreeForMenu($menuId)
{ {
return $this->cache return $this->remember(function () use ($menuId) {
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.getTreeForMenu.{$menuId}",
$this->cacheTime,
function () use ($menuId) {
return $this->repository->getTreeForMenu($menuId); return $this->repository->getTreeForMenu($menuId);
} });
);
} }
/** /**
...@@ -102,15 +78,9 @@ class CacheMenuItemDecorator extends BaseCacheDecorator implements MenuItemRepos ...@@ -102,15 +78,9 @@ class CacheMenuItemDecorator extends BaseCacheDecorator implements MenuItemRepos
*/ */
public function allRootsForMenu($menuId) public function allRootsForMenu($menuId)
{ {
return $this->cache return $this->remember(function () use ($menuId) {
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.allRootsForMenu.{$menuId}",
$this->cacheTime,
function () use ($menuId) {
return $this->repository->allRootsForMenu($menuId); return $this->repository->allRootsForMenu($menuId);
} });
);
} }
/** /**
...@@ -120,14 +90,8 @@ class CacheMenuItemDecorator extends BaseCacheDecorator implements MenuItemRepos ...@@ -120,14 +90,8 @@ class CacheMenuItemDecorator extends BaseCacheDecorator implements MenuItemRepos
*/ */
public function findByUriInLanguage($uri, $locale) public function findByUriInLanguage($uri, $locale)
{ {
return $this->cache return $this->remember(function () use ($uri, $locale) {
->tags([$this->entityName, 'global'])
->remember(
"{$this->locale}.{$this->entityName}.findByUriInLanguage.{$uri}.{$locale}",
$this->cacheTime,
function () use ($uri, $locale) {
return $this->repository->findByUriInLanguage($uri, $locale); return $this->repository->findByUriInLanguage($uri, $locale);
} });
);
} }
} }
url: https://github.com/AsgardCms/Platform url: https://github.com/AsgardCms/Platform
versions: versions:
"3.4.0@unreleased":
changed:
- Using new <code>remember</code> method in the <code>CacheMenuDecorator</code> class
- Using new <code>remember</code> method in the <code>CacheMenuItemDecorator</code> class
"3.2.0": "3.2.0":
changed: changed:
- Use blade directive in Menu module views - Use blade directive in Menu module views
......
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