人人商城

optimize.ctrl.php 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->func('cache');
  8. $dos = array('opcache');
  9. $do = in_array($do, $dos) ? $do : 'index';
  10. $_W['page']['title'] = '性能优化 - 常用系统工具 - 系统管理';
  11. if ($do == 'opcache') {
  12. opcache_reset();
  13. itoast('清空缓存成功', url('system/optimize'), 'success');
  14. } else {
  15. $cache_type = cache_type();
  16. $clear = array('url' => url('system/updatecache'), 'title' => '更新缓存');
  17. $extensions = array(
  18. 'memcache' => array(
  19. 'support' => extension_loaded('memcache'),
  20. 'status' => $cache_type == 'memcache',
  21. 'clear' => $clear
  22. ),
  23. 'redis' => array(
  24. 'support' => extension_loaded('redis'),
  25. 'status' => $cache_type == 'redis',
  26. 'clear' => $clear
  27. ),
  28. 'eAccelerator' => array(
  29. 'support' => function_exists('eaccelerator_optimizer'),
  30. 'status' => function_exists('eaccelerator_optimizer'),
  31. ),
  32. 'opcache' => array(
  33. 'support' => function_exists('opcache_get_configuration'),
  34. 'status' => ini_get('opcache.enable') || ini_get('opcache.enable_cli'),
  35. 'clear' => array(
  36. 'url' => url('system/optimize/opcache'),
  37. 'title' => '清空缓存',
  38. )
  39. )
  40. );
  41. $slave = $_W['config']['db'];
  42. $setting = $_W['config']['setting'];
  43. if ($extensions['memcache']['status']) {
  44. $memobj = cache_memcache();
  45. if (!empty($memobj) && method_exists($memobj, 'getExtendedStats')) {
  46. $status = $memobj->getExtendedStats();
  47. if (!empty($status)) {
  48. foreach ($status as $server => $row) {
  49. $data_status[] = '已用:' . round($row['bytes'] / 1048576, 2) . ' M / 共:' . round($row['limit_maxbytes'] / 1048576) . ' M';
  50. }
  51. $extensions['memcache']['extra'] = ', ' . implode(', ', $data_status);
  52. }
  53. }
  54. }
  55. if ($extensions['redis']['status']) {
  56. $redisobj = cache_redis();
  57. if (!empty($redisobj) && method_exists($redisobj, 'info')) {
  58. $status = $redisobj->info();
  59. if (!empty($status)) {
  60. $extensions['redis']['extra'] = '消耗峰值:' . round($status['used_memory_peak'] / 1048576, 2) . ' M/ 内存总量:' . round($status['used_memory'] / 1048576, 2) . ' M';
  61. }
  62. }
  63. }
  64. template('system/optimize');
  65. }