无限星辰工作室-客户无限互联网动力之源

标题: 让 Discuz!X2 完整支持WinCache [打印本页]

作者: crx349    时间: 2013-8-10 12:38
标题: 让 Discuz!X2 完整支持WinCache
有鉴于Discuz!X2还有很多朋友在用,但是这个版本不支持wincache(win2003和win2008),系统就算是启用了,Discuz!也起不到完整加速的作用,所以才写了以下教程:
修改的文件有3个(source/admincp/admincp_setting.php,source/class/class_core.php,config/config_global.php),新加的文件1个(source/class/class_wincache.php)

1.source/admincp/admincp_setting.php
  1.         $ea = array('eAccelerator',
  2.             $discuz->mem->extension['eaccelerator'] ? cplang('setting_memory_php_enable') : cplang('setting_memory_php_disable'),
  3.             $discuz->mem->config['eaccelerator'] ? cplang('open') : cplang('closed'),
  4.             $discuz->mem->type == 'eaccelerator' ? $do_clear_link : '--'
  5.             );
复制代码
上面添加
  1.         $wincache = array('WinCache',
  2.             $discuz->mem->extension['wincache'] ? cplang('setting_memory_php_enable') : cplang('setting_memory_php_disable'),
  3.             $discuz->mem->config['wincache'] ? cplang('open') : cplang('closed'),
  4.             $discuz->mem->type == 'wincache' ? $do_clear_link : '--'
  5.             );
复制代码
-------------------------------------------------------------------
  1. showtablerow('', '', $ea);
复制代码
上面添加
  1. showtablerow('', '', $wincache);
复制代码
2.source/class/class_core.php
  1. $this->extension['eaccelerator'] = function_exists('eaccelerator_get');
复制代码
上面添加
  1. $this->extension['wincache'] = function_exists('wincache_ucache_get');
复制代码
--------------------------------------------------------------------
  1.         if(!is_object($this->memory) && $this->extension['eaccelerator'] && $this->config['eaccelerator']) {
  2.             require_once libfile('class/eaccelerator');
  3.             $this->memory = new discuz_eaccelerator();
  4.             $this->memory->init(null);
  5.         }
复制代码
上面添加

  1.         if(!is_object($this->memory) && $this->extension['wincache'] && $this->config['wincache']) {
  2.             require_once libfile('class/wincache');
  3.             $this->memory = new discuz_wincache();
  4.             $this->memory->init(null);
  5.         }
复制代码
3.新加文件source/class/class_wincache.php

  1. <?php

  2. /**
  3. *      wincache for Discuz X1.5 By SquallATF
  4. */

  5. class discuz_wincache
  6. {

  7.     function discuz_wincache() {

  8.     }

  9.     function init($config) {

  10.     }

  11.     function get($key) {
  12.         return wincache_ucache_get($key);
  13.     }

  14.     function set($key, $value, $ttl = 0) {
  15.         return wincache_ucache_set($key, $value, $ttl);
  16.     }

  17.     function rm($key) {
  18.         return wincache_ucache_delete($key);
  19.     }

  20. }

  21. ?>
复制代码
4.修改配置文件config/config_global.php
添加
  1. $_config['memory']['wincache'] = 1;
复制代码
适用于windows下iis/apache使用wincache的情况

本插件有无限星辰工作室www.xmspace.net整理发布,转载请注明地址,谢谢!




欢迎光临 无限星辰工作室-客户无限互联网动力之源 (https://www.xmspace.net/) Powered by Discuz! X3.4