/** * Get cache handler. * * Note this cache will ignore the cache setting in Joomla configuration. * * @param string $handler The cache handler name. * @param string $storage The storage name. * * @return \JCache|\JCacheController|\JCacheControllerClosure */ public static function getCache($handler = 'closure', $storage = 'runtime') { static $included = false; if (!$included) { \JCacheStorage::addIncludePath(__DIR__); \JCacheController::addIncludePath(__DIR__); $included = true; } $handler = $handler ?: 'closure'; $cache = \JFactory::getCache('windwalker', $handler, $storage); $cache->setCaching(true); return $cache; }
/** * Returns a reference to a cache adapter object, always creating it * * @param string $type The cache object type to instantiate; default is output. * @param array $options Array of options * * @return JCache A JCache object * * @since 11.1 */ public static function getInstance($type = 'output', $options = array()) { JCacheController::addIncludePath(JPATH_PLATFORM . '/joomla/cache/controller'); $type = strtolower(preg_replace('/[^A-Z0-9_\\.-]/i', '', $type)); $class = 'JCacheController' . ucfirst($type); if (!class_exists($class)) { // Search for the class file in the JCache include paths. jimport('joomla.filesystem.path'); if ($path = JPath::find(JCacheController::addIncludePath(), strtolower($type) . '.php')) { require_once $path; } else { JError::raiseError(500, 'Unable to load Cache Controller: ' . $type); } } return new $class($options); }