Using new remember() helper for menu repositories

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