System.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. /**
  5. * Description of System
  6. *
  7. * @author sgq
  8. */
  9. class System extends AdminController {
  10. /**
  11. * 生成缓存
  12. * @return type
  13. */
  14. public function cache() {
  15. $step = $this->request->param("step");
  16. if ($step) {
  17. $cache_kvs = [
  18. ["func" => "\app\common\model\IntegralProject::cache", "stepName" => "积分项目"],
  19. ["func" => "\app\common\model\IntegralItem::cache", "stepName" => "积分标准"]
  20. ];
  21. $cache = $cache_kvs[$step - 1];
  22. if ($cache) {
  23. $time1 = microtime(true);
  24. $cache["func"]();
  25. $time2 = microtime(true);
  26. $runtime = round($time2 - $time1, 2);
  27. $step++;
  28. echo '<script>window.parent.setText("<span class=\"highlight\">' . $cache["stepName"] . '</span>缓存成功![用时 ' . $runtime . 's]");</script>';
  29. echo '<script>window.location.href="/admin/system/cache/step/' . $step . '";</script>';
  30. } else {
  31. echo '<script>window.parent.setText("缓存创建结束!");</script>';
  32. }
  33. } else {
  34. return view();
  35. }
  36. }
  37. }