Server : nginx/1.22.1 System : Linux iZwz9daxib3w3i063fw434Z 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 User : www ( 1000) PHP Version : 5.6.40 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv Directory : /www/wwwroot/www.jkmold.com/phpcms/libs/classes/ |
<?php /** * cache_factory.class.php 缓存工厂类 * * @copyright (C) 2005-2010 PHPCMS * @license http://www.phpcms.cn/license/ * @lastmodify 2010-6-1 */ final class cache_factory { /** * 当前缓存工厂类静态实例 */ private static $cache_factory; /** * 缓存配置列表 */ protected $cache_config = array(); /** * 缓存操作实例化列表 */ protected $cache_list = array(); /** * 构造函数 */ public function __construct() { } /** * 返回当前终级类对象的实例 * @param $cache_config 缓存配置 * @return object */ public static function get_instance($cache_config = '') { if(cache_factory::$cache_factory == '' || $cache_config !='') { cache_factory::$cache_factory = new cache_factory(); if(!empty($cache_config)) { cache_factory::$cache_factory->cache_config = $cache_config; } } return cache_factory::$cache_factory; } /** * 获取缓存操作实例 * @param $cache_name 缓存配置名称 */ public function get_cache($cache_name) { if(!isset($this->cache_list[$cache_name]) || !is_object($this->cache_list[$cache_name])) { $this->cache_list[$cache_name] = $this->load($cache_name); } return $this->cache_list[$cache_name]; } /** * 加载缓存驱动 * @param $cache_name 缓存配置名称 * @return object */ public function load($cache_name) { $object = null; if(isset($this->cache_config[$cache_name]['type'])) { switch($this->cache_config[$cache_name]['type']) { case 'file' : $object = pc_base::load_sys_class('cache_file'); break; case 'memcache' : define('MEMCACHE_HOST', $this->cache_config[$cache_name]['hostname']); define('MEMCACHE_PORT', $this->cache_config[$cache_name]['port']); define('MEMCACHE_TIMEOUT', $this->cache_config[$cache_name]['timeout']); define('MEMCACHE_DEBUG', $this->cache_config[$cache_name]['debug']); $object = pc_base::load_sys_class('cache_memcache'); break; case 'apc' : $object = pc_base::load_sys_class('cache_apc'); break; default : $object = pc_base::load_sys_class('cache_file'); } } else { $object = pc_base::load_sys_class('cache_file'); } return $object; } } ?>