public function __construct($options = array()) { $this->_root = JPATH_ADMINISTRATOR . '/cache'; $this->_hash = JFactory::getConfig()->get('secret'); $cache = new JCacheStorage(); $this->_cache = $cache->getInstance('file', array('cachebase' => $this->_root)); }
function __construct($options = array()) { $config =& JFactory::getConfig(); jimport('joomla.cache.cache'); $cache = new JCacheStorage(); $this->_cache = $cache->getInstance('file', array('cachebase' => JPATH_ADMINISTRATOR . DS . 'cache')); $this->_root = JPATH_ADMINISTRATOR . DS . 'cache'; $this->_hash = $config->getValue('config.secret'); }
/** * Constructor * * @param array $options optional parameters */ function __construct( $options = array() ) { parent::__construct($options); $config =& JFactory::getConfig(); $this->_hash = $config->get('secret'); }
/** * Testing test(). * * @return void */ public function testTest() { $this->assertThat( $this->object->test(), $this->isTrue() ); }
/** * Constructor * * @access protected * @param array $options optional parameters */ function __construct($options = array()) { if (!$this->test()) { return JError::raiseError(404, "The memcache extension is not available"); } parent::__construct($options); $config =& JFactory::getConfig(); $params = $config->getValue('config.memcache_settings'); if (!is_array($params)) { $params = unserialize(stripslashes($params)); } if (!$params) { $params = array(); } $this->_compress = isset($params['compression']) ? $params['compression'] : 0; $this->_persistent = isset($params['persistent']) ? $params['persistent'] : false; // This will be an array of loveliness $this->_servers = isset($params['servers']) ? $params['servers'] : array(); // Create the memcache connection $this->_db = new Memcache(); for ($i = 0, $n = count($this->_servers); $i < $n; $i++) { $server = $this->_servers[$i]; $this->_db->addServer($server['host'], $server['port'], $this->_persistent); } // Get the site hash $this->_hash = $config->getValue('config.secret'); }
/** * Get all cached data * * This requires the php.ini setting xcache.admin.enable_auth = Off. * * @return array data * * @since 11.1 */ public function getAll() { parent::getAll(); // Make sure XCache is configured properly if (self::isSupported() == false) { return array(); } $allinfo = xcache_list(XC_TYPE_VAR, 0); $keys = $allinfo['cache_list']; $secret = $this->_hash; $data = array(); foreach ($keys as $key) { $namearr = explode('-', $key['name']); if ($namearr !== false && $namearr[0] == $secret && $namearr[1] == 'cache') { $group = $namearr[2]; if (!isset($data[$group])) { $item = new JCacheStorageHelper($group); } else { $item = $data[$group]; } $item->updateSize($key['size'] / 1024); $data[$group] = $item; } } return $data; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { include_once JPATH_PLATFORM . '/joomla/cache/storage.php'; include_once JPATH_PLATFORM . '/joomla/cache/storage/xcache.php'; $this->xcacheAvailable = extension_loaded('xcache'); $this->object = JCacheStorage::getInstance('xcache'); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { parent::setUp(); $xcachetest = false; if (extension_loaded('xcache')) { // XCache Admin must be disabled for Joomla to use XCache $xcache_admin_enable_auth = ini_get('xcache.admin.enable_auth'); // Some extensions ini variables are reported as strings if ($xcache_admin_enable_auth == 'Off') { $xcachetest = true; } // We require a string with contents 0, not a null value because it is not set since that then defaults to On/True if ($xcache_admin_enable_auth === '0') { $xcachetest = true; } // In some enviorments empty is equivalent to Off; See JC: #34044 && Github: #4083 if ($xcache_admin_enable_auth === '') { $xcachetest = true; } } $this->extensionAvailable = $xcachetest; if ($this->extensionAvailable) { $this->object = JCacheStorage::getInstance('xcache'); } else { $this->markTestSkipped('This caching method is not supported on this system.'); } }
/** * Constructor * * @param array $options Optional parameters. * * @since 12.1 */ public function __construct($options = array()) { parent::__construct($options); if (static::isSupported() && static::$_db === null) { $this->getConnection(); } }
/** * Testing isSupported(). * * @return void */ public function testIsSupported() { $this->assertThat( $this->object->isSupported(), $this->isTrue() ); }
/** * Get all cached data * * @return array data * @since 11.1 */ public function getAll() { parent::getAll(); $allinfo = wincache_ucache_info(); $keys = $allinfo['cache_entries']; $secret = $this->_hash; $data = array(); foreach ($keys as $key) { $name = $key['key_name']; $namearr = explode('-', $name); if ($namearr !== false && $namearr[0] == $secret && $namearr[1] == 'cache') { $group = $namearr[2]; if (!isset($data[$group])) { $item = new JCacheStorageHelper($group); } else { $item = $data[$group]; } if (isset($key['value_size'])) { $item->updateSize($key['value_size'] / 1024); } else { // Dummy, WINCACHE version is too low $item->updateSize(1); } $data[$group] = $item; } } return $data; }
/** * Constructor * * @param array $options Optional parameters. * * @since 3.4 */ public function __construct($options = array()) { parent::__construct($options); if (static::$_redis === null) { $this->getConnection(); } }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void * @access protected */ protected function setUp() { $memcachetest = false; include_once JPATH_BASE.'/libraries/joomla/cache/storage.php'; include_once JPATH_BASE.'/libraries/joomla/cache/storage/memcache.php'; if((extension_loaded('memcache') && class_exists('Memcache')) != true ) { $this->memcacheAvailable = false; } else { $config = JFactory::getConfig(); $host = $config->get('memcache_server_host', 'localhost'); $port = $config->get('memcache_server_port',11211); $memcache = new Memcache; $memcachetest = @$memcache->connect($host, $port); } if (!$memcachetest) { $this->memcacheAvailable = false; } else $this->memcacheAvailable = true; if ($this->memcacheAvailable) { $this->object = JCacheStorage::getInstance('memcache'); } }
/** * Constructor * * @access protected * @param array $options optional parameters */ function __construct($options = array()) { parent::__construct($options); $config =& JFactory::getConfig(); $this->_root = $options['cachebase']; $this->_hash = $config->getValue('config.secret'); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void * @access protected */ protected function setUp() { include_once JPATH_BASE . '/libraries/joomla/cache/storage.php'; include_once JPATH_BASE . '/libraries/joomla/cache/storage/eaccelerator.php'; $this->eacceleratorAvailable = extension_loaded('eaccelerator') && function_exists('eaccelerator_get'); $this->object = JCacheStorage::getInstance('eaccelerator'); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { include_once JPATH_PLATFORM . '/joomla/cache/storage.php'; include_once JPATH_PLATFORM . '/joomla/cache/storage/file.php'; $this->object = JCacheStorage::getInstance('file', array('cachebase' => JPATH_BASE . '/cache')); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void * @access protected */ protected function setUp() { include_once JPATH_BASE . '/libraries/joomla/cache/storage.php'; include_once JPATH_BASE . '/libraries/joomla/cache/storage/apc.php'; $this->object = JCacheStorage::getInstance('apc'); $this->apcAvailable = extension_loaded('apc'); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { parent::setUp(); include_once JPATH_PLATFORM . '/joomla/cache/storage.php'; include_once JPATH_PLATFORM . '/joomla/cache/storage/apc.php'; $this->object = JCacheStorage::getInstance('apc'); $this->apcAvailable = extension_loaded('apc'); }
/** * Constructor * * @param array $options Optional parameters. * * @since 11.1 */ public function __construct($options = array()) { parent::__construct($options); $this->_root = $options['cachebase']; $cloptions = array('cacheDir' => $this->_root . '/', 'lifeTime' => $this->_lifetime, 'fileLocking' => $this->_locking, 'automaticCleaningFactor' => isset($options['autoclean']) ? $options['autoclean'] : 200, 'fileNameProtection' => false, 'hashedDirectoryLevel' => 0, 'caching' => $options['caching']); if (static::$CacheLiteInstance === null) { $this->initCache($cloptions); } }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { parent::setUp(); $this->extensionAvailable = extension_loaded('wincache') && function_exists('wincache_ucache_get') && !strcmp(ini_get('wincache.ucenabled'), '1'); if ($this->extensionAvailable) { $this->object = JCacheStorage::getInstance('wincache'); } else { $this->markTestSkipped('This caching method is not supported on this system.'); } }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { parent::setUp(); $this->extensionAvailable = JCacheStorageApcu::isSupported(); if ($this->extensionAvailable) { $this->object = JCacheStorage::getInstance('apcu'); } else { $this->markTestSkipped('This caching method is not supported on this system.'); } }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { parent::setUp(); $this->extensionAvailable = is_writable(JPATH_BASE . '/cache'); if ($this->extensionAvailable) { $this->object = JCacheStorage::getInstance('file', array('cachebase' => JPATH_BASE . '/cache')); } else { $this->markTestSkipped('This caching method is not supported on this system.'); } }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { parent::setUp(); $this->extensionAvailable = class_exists('Cache_Lite'); if ($this->extensionAvailable) { $options = array('cachebase' => JPATH_TESTS . '/tmp', 'caching' => true); $this->object = JCacheStorage::getInstance('cachelite', $options); } else { $this->markTestSkipped('This caching method is not supported on this system.'); } }
/** * Constructor * * @access protected * @param array $options optional parameters */ function __construct($options = array()) { if (!$this->test()) { return JError::raiseError(404, "The memcache extension is not available"); } parent::__construct($options); $params =& JCacheStorageMemcache::getConfig(); $this->_compress = isset($params['compression']) ? $params['compression'] : 0; $this->_db =& JCacheStorageMemcache::getConnection(); // Get the site hash $this->_hash = $params['hash']; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void * * @since 3.4 */ protected function setUp() { parent::setUp(); $this->saveFactoryState(); JFactory::$application = $this->getMockCmsApp(); $this->extensionAvailable = class_exists('Redis'); if ($this->extensionAvailable) { $this->object = JCacheStorage::getInstance('redis'); } else { $this->markTestSkipped('This caching method is not supported on this system.'); } }
/** * Constructor * * @access protected * @param array $options optional parameters */ function __construct($options = array()) { if (!$this->test()) { return JError::raiseError(404, "THE_MEMCACHE_EXTENSION_IS_NOT_AVAILABLE"); } parent::__construct($options); $params =& JCacheStorageMemcache::getConfig(); $this->_compress = isset($params['compression']) ? $params['compression'] : 0; $this->_db =& JCacheStorageMemcache::getConnection(); // Get the site hash $this->_hash = $params['hash']; }
/** * 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; }
/** * Constructor * * @access protected * @param array $options optional parameters */ function __construct($options = array()) { if (!$this->test()) { return JError::raiseError(404, "The memcache extension is not available"); } parent::__construct($options); $params =& JCacheStorageMemcache::getConfig(); $this->_compress = isset($params['compression']) ? $params['compression'] : 0; $this->_db =& JCacheStorageMemcache::getConnection(); // memcahed has no list keys, we do our own accounting, initalise key index if ($this->_db->get($this->_hash . '-index') === false) { $empty = array(); $this->_db->set($this->_hash . '-index', $empty, $this->_compress, 0); } }
/** * Get all cached data * * @return array The cached data * * @since 11.1 */ public function getAll() { parent::getAll(); $path = $this->_root; $folders = $this->_folders($path); $data = array(); foreach ($folders as $folder) { $files = $this->_filesInFolder($path . '/' . $folder); $item = new JCacheStorageHelper($folder); foreach ($files as $file) { $item->updateSize(filesize($path . '/' . $folder . '/' . $file) / 1024); } $data[$folder] = $item; } return $data; }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { $memcachetest = false; if (extension_loaded('memcache') || class_exists('Memcache')) { $config = JFactory::getConfig(); $host = $config->get('memcache_server_host', 'localhost'); $port = $config->get('memcache_server_port', 11211); $memcache = new Memcache(); $memcachetest = @$memcache->connect($host, $port); } $this->extensionAvailable = $memcachetest; if ($this->extensionAvailable) { $this->object = JCacheStorage::getInstance('memcache'); } else { $this->markTestSkipped('This caching method is not supported on this system.'); } }