Merge pull request !34 from 耐小心/YacCache
This commit is contained in:
commit
6c6bf10c06
|
@ -115,6 +115,7 @@ $_config['memory']['apc'] = 1; // 启动对 apc 的支持
|
|||
$_config['memory']['xcache'] = 1; // 启动对 xcache 的支持
|
||||
$_config['memory']['eaccelerator'] = 1; // 启动对 eaccelerator 的支持
|
||||
$_config['memory']['wincache'] = 1; // 启动对 wincache 的支持
|
||||
$_config['memory']['yac'] = 1; //启动对 YAC的支持
|
||||
// 服务器相关设置
|
||||
$_config['server']['id'] = 1; // 服务器编号,多webserver的时候,用于标识当前服务器的ID
|
||||
|
||||
|
@ -196,4 +197,4 @@ $_config['input']['compatible'] = 1;
|
|||
// )
|
||||
//);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -2242,13 +2242,18 @@ EOT;
|
|||
$cache_config['wincache'] ? cplang('open') : cplang('closed'),
|
||||
$cache_type == 'wincache' ? $do_clear_link : '--'
|
||||
);
|
||||
|
||||
$yac = array('Yac',
|
||||
$cache_extension['yac'] ? cplang('setting_memory_php_enable') : cplang('setting_memory_php_disable'),
|
||||
$cache_config['yac'] ? cplang('open') : cplang('closed'),
|
||||
$cache_type == 'yac' ? $do_clear_link : '--'
|
||||
);
|
||||
showtablerow('', array('width="100"', 'width="120"', 'width="120"'), $redis);
|
||||
showtablerow('', '', $memcache);
|
||||
showtablerow('', '', $apc);
|
||||
showtablerow('', '', $xcache);
|
||||
showtablerow('', '', $ea);
|
||||
showtablerow('', '', $wincache);
|
||||
showtablerow('', '', $yac);
|
||||
showtablefooter();
|
||||
|
||||
if(!isset($setting['memory'])) {
|
||||
|
@ -3686,4 +3691,4 @@ function showsetting_threadprfile($authorinfoitems, $template = array()) {
|
|||
<tr><td colspan="2"><div class="threadprofilenode">'.$buttons.'</div><textarea name="templatenew[top]" id="ttop" class="marginbot" style="width:80%" rows="10" onkeyup="textareasize(this)" onkeydown="textareakey(this, event)">'.$template_top.'</textarea></td></tr>';
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -29,6 +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');
|
||||
}
|
||||
|
||||
public function init($config) {
|
||||
|
@ -52,7 +54,7 @@ class discuz_memory extends discuz_base
|
|||
}
|
||||
}
|
||||
|
||||
foreach(array('apc', 'eaccelerator', 'xcache', 'wincache') as $cache) {
|
||||
foreach(array('apc', 'eaccelerator', 'xcache', 'wincache','yac') as $cache) {
|
||||
if(!is_object($this->memory) && $this->extension[$cache] && $this->config[$cache]) {
|
||||
$class_name = 'memory_driver_'.$cache;
|
||||
$this->memory = new $class_name();
|
||||
|
@ -189,4 +191,4 @@ class discuz_memory extends discuz_base
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* [Discuz!] (C)2001-2099 Comsenz Inc.
|
||||
* This is NOT a freeware, use is subject to license terms
|
||||
*
|
||||
* $Id: memory_driver_yac.php 27635 2017-02-02 17:02:46Z NaiXiaoxIN $
|
||||
*/
|
||||
|
||||
if(!defined('IN_DISCUZ')) {
|
||||
exit('Access Denied');
|
||||
}
|
||||
|
||||
class memory_driver_yac
|
||||
{
|
||||
|
||||
private $object = null;
|
||||
|
||||
public function init($config) {
|
||||
$this->object = new yac();
|
||||
}
|
||||
|
||||
public function get($key) {
|
||||
return $this->object->get($key);
|
||||
}
|
||||
|
||||
public function getMulti($keys) {
|
||||
$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) {
|
||||
return $this->object->set($key, $value, $ttl);
|
||||
}
|
||||
|
||||
public function rm($key) {
|
||||
return $this->object->delete($key);
|
||||
}
|
||||
|
||||
public function clear() {
|
||||
return $this->object->flush();
|
||||
}
|
||||
|
||||
public function inc($key, $step = 1) {
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1537,7 +1537,7 @@ $lang = array
|
|||
'setting_cachethread_coefficient_forum_comment' => '将会覆盖以前的缓存系数值,可以按住 CTRL 多选',
|
||||
|
||||
'setting_memory' => '内存优化',
|
||||
'setting_memory_tips' => '<li>启用内存优化功能将会大幅度提升程序性能和服务器的负载能力,内存优化功能需要服务器系统以及PHP扩展模块支持</li><li>目前支持的内存优化接口有 Memcache、eAccelerator、Alternative PHP Cache(APC)、Xcache、Redis 五种,优化系统将会依据当前服务器环境依次选用接口</li><li>内存接口的主要设置位于 config_global.php 当中,您可以通过编辑 config_global.php 进行高级设置</li>',
|
||||
'setting_memory_tips' => '<li>启用内存优化功能将会大幅度提升程序性能和服务器的负载能力,内存优化功能需要服务器系统以及PHP扩展模块支持</li><li>目前支持的内存优化接口有 Memcache、eAccelerator、Alternative PHP Cache(APC)、YAC、Xcache、Redis 五种,优化系统将会依据当前服务器环境依次选用接口</li><li>内存接口的主要设置位于 config_global.php 当中,您可以通过编辑 config_global.php 进行高级设置</li>',
|
||||
'setting_memory_status' => '当前内存工作状态',
|
||||
'setting_memory_php_enable' => '支持',
|
||||
'setting_memory_php_disable' => '不支持',
|
||||
|
@ -7101,4 +7101,4 @@ if(file_exists($adminextendfile = DISCUZ_ROOT.'./data/sysdata/cache_adminextend.
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue