From 31757c94df8fae8d5f32e5d7d909fa76744dab9e Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 16 Jun 2022 10:37:08 +0200 Subject: [PATCH] wip #4210 --- src/app/Permissions.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/app/Permissions.php b/src/app/Permissions.php index 209ca52..130f038 100644 --- a/src/app/Permissions.php +++ b/src/app/Permissions.php @@ -9,17 +9,15 @@ class Permissions { protected static $_data = false; - public static function _getData() + public static function _getData($force = false) { - if (self::$_data !== false) { + if (!$force && self::$_data !== false) { return self::$_data; } $cacheKey = 'cubedesigners_userdatabase_permissions_data'; - \Barryvdh\Debugbar\Facade::startMeasure($cacheKey, 'Build permissions tree'); - self::$_data = cache()->tags(['model_' . Company::class, 'model_' . User::class])->remember($cacheKey, 86400, function () { - + $closure = function () { set_time_limit(0); $data = [ @@ -94,8 +92,19 @@ class Permissions } return $data; - }); + }; + + \Barryvdh\Debugbar\Facade::startMeasure($cacheKey, 'Build permissions tree'); + $cache = cache()->tags(['model_' . Company::class, 'model_' . User::class]); + $ttl = 86400; + if ($force) { + self::$_data = $closure(); + $cache->put($cacheKey, $ttl, self::$_data); + } else { + self::$_data = cache()->remember($cacheKey, $ttl, $closure); + } \Barryvdh\Debugbar\Facade::stopMeasure($cacheKey); + return self::$_data; } -- 2.39.5