HomeAction::cacheConfig PHP Method

cacheConfig() public method

缓存配置
public cacheConfig ( )
    public function cacheConfig()
    {
        if ($_POST) {
            $cachetype = t($_POST['cachetype']);
            //已测试通过
            if ($cachetype == 'Memcache' && !extension_loaded('memcache')) {
                $this->error('无法启用该服务,服务器没有安装Memcache扩展。');
            }
            //已测试通过
            if ($cachetype == 'APC' && !function_exists('apc_cache_info')) {
                $this->error('无法启用该服务,服务器没有安装APC扩展。');
            }
            //已测试通过
            if ($cachetype == 'Xcache' && !function_exists('xcache_info')) {
                $this->error('无法启用该服务,服务器没有安装Xcache扩展。');
            }
            //没环境测试
            if ($cachetype == 'Redis' && !extension_loaded('Redis')) {
                $this->error('无法启用该服务,服务器没有安装Redis扩展。');
            }
            //没环境测试
            if ($cachetype == 'WinCache' && !function_exists('wincache_ucache_info')) {
                $this->error('无法启用该服务,服务器没有安装WinCache扩展。');
            }
            //貌似不靠谱还没搞定
            if ($cachetype == 'Eaccelerator' && !function_exists('eaccelerator_get')) {
                $this->error('无法启用该服务,服务器没有安装eAccelerator扩展。');
            }
            $cachesetting = t($_POST['cachesetting']);
            model('Xdata')->saveKey('cacheconfig:cachetype', $cachetype);
            model('Xdata')->saveKey('cacheconfig:cachesetting', $cachesetting);
            $this->success('保存成功');
        }
        $this->pageKeyList = array('cachetype', 'cachesetting', 'status');
        $this->opt['cachetype'] = array('File' => '文件缓存', 'Xcache' => 'Xcache', 'APC' => 'APC', 'Memcache' => 'Memcache');
        model('Cache')->set('testCacheStatus', '123456789');
        $status = model('Cache')->get('testCacheStatus');
        model('Cache')->rm('testCacheStatus');
        $this->opt['status'] = $status == '123456789' ? array('正常') : array('不正常');
        $data['cachetype'] = model('Xdata')->get('cacheconfig:cachetype');
        !$data['cachetype'] && ($data['cachetype'] = 'file');
        $data['cachesetting'] = model('Xdata')->get('cacheconfig:cachesetting');
        $this->savePostUrl = U('admin/Home/cacheConfig');
        $this->displayConfig($data);
    }