Browse Source

修改缓存清除

liaofei 6 years ago
parent
commit
bbac300a43
2 changed files with 29 additions and 1 deletions
  1. 28 0
      crmeb/app/common.php
  2. 1 1
      crmeb/crmeb/services/CacheService.php

+ 28 - 0
crmeb/app/common.php

@@ -150,4 +150,32 @@ if (!function_exists('sysData')) {
     {
         return app('sysGroupData')->getData($name);
     }
+}
+
+if (!function_exists('sort_list_tier')) {
+    /**
+     * 分级排序
+     * @param $data
+     * @param int $pid
+     * @param string $field
+     * @param string $pk
+     * @param string $html
+     * @param int $level
+     * @param bool $clear
+     * @return array
+     */
+    function sort_list_tier($data, $pid = 0, $field = 'pid', $pk = 'id', $html = '|-----', $level = 1, $clear = true)
+    {
+        static $list = [];
+        if ($clear) $list = [];
+        foreach ($data as $k => $res) {
+            if ($res[$field] == $pid) {
+                $res['html'] = str_repeat($html, $level);
+                $list[] = $res;
+                unset($data[$k]);
+                sort_list_tier($data, $res[$pk], $field, $pk, $html, $level + 1, false);
+            }
+        }
+        return $list;
+    }
 }

+ 1 - 1
crmeb/crmeb/services/CacheService.php

@@ -85,6 +85,6 @@ class CacheService
      */
     public static function clear()
     {
-        return CacheStatic::clear(self::$globalCacheName);
+        return self::handler()->clear();
     }
 }