Skip to content

Commit

Permalink
Using new remember() helper for menu repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Nov 20, 2017
1 parent fee36dc commit a047aef
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 63 deletions.
12 changes: 3 additions & 9 deletions Modules/Menu/Repositories/Cache/CacheMenuDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ public function __construct(MenuRepository $menu)
*/
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();
});
}
}
72 changes: 18 additions & 54 deletions Modules/Menu/Repositories/Cache/CacheMenuItemDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,9 @@ public function __construct(MenuItemRepository $menuItem)
*/
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);
});
}

/**
Expand All @@ -45,15 +39,9 @@ function () use ($menuId) {
*/
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();
});
}

/**
Expand All @@ -64,15 +52,9 @@ function () {
*/
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);
});
}

/**
Expand All @@ -83,15 +65,9 @@ function () use ($menuId) {
*/
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);
});
}

/**
Expand All @@ -102,15 +78,9 @@ function () use ($menuId) {
*/
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);
});
}

/**
Expand All @@ -120,14 +90,8 @@ function () use ($menuId) {
*/
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);
});
}
}
4 changes: 4 additions & 0 deletions Modules/Menu/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
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
Expand Down

0 comments on commit a047aef

Please sign in to comment.