]> _ Git - cubedesigners_userdatabase.git/commitdiff
wip #4210
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Jun 2022 08:37:08 +0000 (10:37 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Jun 2022 08:37:08 +0000 (10:37 +0200)
src/app/Permissions.php

index 209ca52a88c1feaaf7e30fd8cd588a8938969517..130f0388508893b8f4e43777994e5e2906285941 100644 (file)
@@ -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;
     }