/** * Includes the cache_class file, returns a verified cache class */ function &get_cache_class() { static $settings; static $class; $type = $this->get_cache_type(); if (!isset($class[$type])) { if (!isset($settings)) { $cts = new CacheTypeSettings(); $settings =& $cts->get_settings(); } $is_defined = isset($settings[$type]); $file_path = isset($settings[$type]['path']) ? $settings[$type]['path'] : false; if ($is_defined && $file_path) { include_once $file_path; $cache_class_name[$type] = isset($settings[$type]['classname']) ? $settings[$type]['classname'] : ucfirst(basename($file_path, ".php")) . 'ObjectCache'; // create an instance and run setup methods $cache = new $cache_class_name[$type](); $cache->setup_constants($settings[$type]['constants']); $cache->setup_custom($settings[$type]); } if (!$is_defined) { $class[$type] = NULL; } elseif ($file_path && $cache->validate()) { $class[$type] =& $cache; } else { $class[$type] = false; } } return $class[$type]; }
/** * Includes the cache_class file, returns a verified cache class */ function &get_cache_class() { static $settings; static $class; $type = $this->get_cache_type(); if (!isset($class[$type])) { if (!isset($settings)) { $cts = new CacheTypeSettings(); $settings =& $cts->get_settings(); } $is_defined = isset($settings[$type]); $file_path = isset($settings[$type]['path']) ? $settings[$type]['path'] : false; if ($is_defined && file_exists($file_path)) { include_once $file_path; $cache_class_name[$type] = isset($settings[$type]['classname']) ? $settings[$type]['classname'] : ucfirst(basename($file_path, ".php")) . 'ObjectCache'; // create an instance and run setup methods $class[$type] = isset($settings[$type]) ? new $cache_class_name[$type]('do_not_instantiate_me_directly', $settings[$type]) : new $cache_class_name[$type]('do_not_instantiate_me_directly'); } else { if (!$is_defined) { trigger_error('The cache type you requested (' . $this->get_cache_type() . ') in not defined in object_cache_settings.php. The cache will not be used.'); } else { trigger_error('The cache type file (' . $file_path . ') could not be found object_cache_settings.php. The cache will not be used.'); } $class[$type] = false; } } return $class[$type]; }