From a047aef0a6197b096c1af83e78aea4a52a90ff56 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Mon, 20 Nov 2017 19:07:07 +0100 Subject: [PATCH] Using new remember() helper for menu repositories --- .../Repositories/Cache/CacheMenuDecorator.php | 12 +--- .../Cache/CacheMenuItemDecorator.php | 72 +++++-------------- Modules/Menu/changelog.yml | 4 ++ 3 files changed, 25 insertions(+), 63 deletions(-) diff --git a/Modules/Menu/Repositories/Cache/CacheMenuDecorator.php b/Modules/Menu/Repositories/Cache/CacheMenuDecorator.php index 2a6bb171a..e632c981e 100644 --- a/Modules/Menu/Repositories/Cache/CacheMenuDecorator.php +++ b/Modules/Menu/Repositories/Cache/CacheMenuDecorator.php @@ -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(); + }); } } diff --git a/Modules/Menu/Repositories/Cache/CacheMenuItemDecorator.php b/Modules/Menu/Repositories/Cache/CacheMenuItemDecorator.php index 9aaf85c96..5e4591a11 100644 --- a/Modules/Menu/Repositories/Cache/CacheMenuItemDecorator.php +++ b/Modules/Menu/Repositories/Cache/CacheMenuItemDecorator.php @@ -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); + }); } /** @@ -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(); + }); } /** @@ -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); + }); } /** @@ -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); + }); } /** @@ -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); + }); } /** @@ -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); + }); } } diff --git a/Modules/Menu/changelog.yml b/Modules/Menu/changelog.yml index 934bce8cd..4dc44608b 100644 --- a/Modules/Menu/changelog.yml +++ b/Modules/Menu/changelog.yml @@ -1,5 +1,9 @@ url: https://github.com/AsgardCms/Platform versions: + "3.4.0@unreleased": + changed: + - Using new remember method in the CacheMenuDecorator class + - Using new remember method in the CacheMenuItemDecorator class "3.2.0": changed: - Use blade directive in Menu module views