diff --git a/upload/config/config_global_default.php b/upload/config/config_global_default.php index 1a9ddc9..c10b824 100644 --- a/upload/config/config_global_default.php +++ b/upload/config/config_global_default.php @@ -4,7 +4,7 @@ * [Discuz!] (C)2001-2099 Comsenz Inc. * This is NOT a freeware, use is subject to license terms * - * $Id: config_global_default.php 36287 2016-12-12 03:59:05Z nemohou $ + * $Id: config_global_default.php 36362 2017-02-04 02:02:03Z nemohou $ */ $_config = array(); @@ -111,11 +111,12 @@ $_config['memory']['memcache']['port'] = 11211; // memcache 服务器端口 $_config['memory']['memcache']['pconnect'] = 1; // memcache 是否长久连接 $_config['memory']['memcache']['timeout'] = 1; // memcache 服务器连接超时 -$_config['memory']['apc'] = 1; // 启动对 apc 的支持 +$_config['memory']['apc'] = 1; // 启动对 APC 的支持 +$_config['memory']['apcu'] = 1; // 启动对 APCu 的支持 $_config['memory']['xcache'] = 1; // 启动对 xcache 的支持 $_config['memory']['eaccelerator'] = 1; // 启动对 eaccelerator 的支持 $_config['memory']['wincache'] = 1; // 启动对 wincache 的支持 -$_config['memory']['yac'] = 1; //启动对 YAC的支持 +$_config['memory']['yac'] = 1; //启动对 YAC的支持 // 服务器相关设置 $_config['server']['id'] = 1; // 服务器编号,多webserver的时候,用于标识当前服务器的ID @@ -197,4 +198,4 @@ $_config['input']['compatible'] = 1; // ) //); -?> +?> \ No newline at end of file diff --git a/upload/source/admincp/admincp_setting.php b/upload/source/admincp/admincp_setting.php index d287eab..10a6de5 100644 --- a/upload/source/admincp/admincp_setting.php +++ b/upload/source/admincp/admincp_setting.php @@ -4,7 +4,7 @@ * [Discuz!] (C)2001-2099 Comsenz Inc. * This is NOT a freeware, use is subject to license terms * - * $Id: admincp_setting.php 36349 2017-01-16 03:05:23Z nemohou $ + * $Id: admincp_setting.php 36362 2017-02-04 02:02:03Z nemohou $ */ if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) { exit('Access Denied'); @@ -2247,6 +2247,11 @@ EOT; $cache_config['yac'] ? cplang('open') : cplang('closed'), $cache_type == 'yac' ? $do_clear_link : '--' ); + $apcu = array('APCu', + $cache_extension['apcu'] ? cplang('setting_memory_php_enable') : cplang('setting_memory_php_disable'), + $cache_config['apcu'] ? cplang('open') : cplang('closed'), + $cache_type == 'apcu' ? $do_clear_link : '--' + ); showtablerow('', array('width="100"', 'width="120"', 'width="120"'), $redis); showtablerow('', '', $memcache); showtablerow('', '', $apc); @@ -2254,6 +2259,7 @@ EOT; showtablerow('', '', $ea); showtablerow('', '', $wincache); showtablerow('', '', $yac); + showtablerow('', '', $apcu); showtablefooter(); if(!isset($setting['memory'])) { @@ -3691,4 +3697,4 @@ function showsetting_threadprfile($authorinfoitems, $template = array()) {
'.$buttons.'
'; } -?> +?> \ No newline at end of file diff --git a/upload/source/class/discuz/discuz_memory.php b/upload/source/class/discuz/discuz_memory.php index 015c086..fd20885 100644 --- a/upload/source/class/discuz/discuz_memory.php +++ b/upload/source/class/discuz/discuz_memory.php @@ -4,7 +4,7 @@ * [Discuz!] (C)2001-2099 Comsenz Inc. * This is NOT a freeware, use is subject to license terms * - * $Id: discuz_memory.php 31432 2012-08-28 03:04:18Z zhangguosheng $ + * $Id: discuz_memory.php 36362 2017-02-04 02:02:03Z nemohou $ */ if(!defined('IN_DISCUZ')) { @@ -29,8 +29,8 @@ class discuz_memory extends discuz_base $this->extension['xcache'] = function_exists('xcache_get'); $this->extension['eaccelerator'] = function_exists('eaccelerator_get'); $this->extension['wincache'] = function_exists('wincache_ucache_meminfo') && wincache_ucache_meminfo(); - $this->extension['xcache'] = function_exists('xcache_get'); - $this->extension['yac'] = extension_loaded('Yac'); + $this->extension['yac'] = extension_loaded('Yac'); + $this->extension['apcu'] = function_exists('apcu_cache_info') && @apcu_cache_info(); } public function init($config) { @@ -54,7 +54,7 @@ class discuz_memory extends discuz_base } } - foreach(array('apc', 'eaccelerator', 'xcache', 'wincache','yac') as $cache) { + foreach(array('apc', 'eaccelerator', 'xcache', 'wincache', 'yac', 'apcu') as $cache) { if(!is_object($this->memory) && $this->extension[$cache] && $this->config[$cache]) { $class_name = 'memory_driver_'.$cache; $this->memory = new $class_name(); @@ -191,4 +191,4 @@ class discuz_memory extends discuz_base } } -?> +?> \ No newline at end of file diff --git a/upload/source/class/memory/memory_driver_apcu.php b/upload/source/class/memory/memory_driver_apcu.php new file mode 100644 index 0000000..ab65ef7 --- /dev/null +++ b/upload/source/class/memory/memory_driver_apcu.php @@ -0,0 +1,51 @@ +object = new yac(); + $this->object = new yac(); } public function get($key) { @@ -25,13 +23,13 @@ class memory_driver_yac } public function getMulti($keys) { - $result = $this->object->get($keys); - foreach ($result as $key => $value) { - if($value===false){ - unset($result[$key]); - } - } - return $result; + $result = $this->object->get($keys); + foreach ($result as $key => $value) { + if ($value === false) { + unset($result[$key]); + } + } + return $result; } public function set($key, $value, $ttl = 0) { @@ -39,7 +37,7 @@ class memory_driver_yac } public function rm($key) { - return $this->object->delete($key); + return $this->object->delete($key); } public function clear() { @@ -47,19 +45,19 @@ class memory_driver_yac } public function inc($key, $step = 1) { - $old = $this->get($key); - if(!$old){ - return false; - } - return $this->set($key,$old+$step); + $old = $this->get($key); + if (!$old) { + return false; + } + return $this->set($key, $old + $step); } public function dec($key, $step = 1) { - $old = $this->get($key); - if(!$old){ - return false; - } - return $this->set($key,$old-$step); + $old = $this->get($key); + if (!$old) { + return false; + } + return $this->set($key, $old - $step); } -} +} \ No newline at end of file