public function __construct($groupName, $lifeTime = self::DEFAULT_LIFETIME)
 {
     $this->lifeTime = $lifeTime;
     $this->cache =& JFactory::getCache($groupName, 'output');
     $this->cache->setCaching(true);
     $this->cache->setLifeTime($this->lifeTime);
 }
 public function __construct($groupName, $lifeTime = self::DEFAULT_LIFETIME)
 {
     $this->lifeTime = $lifeTime;
     $this->cache = JFactory::getCache($groupName, 'output');
     $conf = JFactory::getConfig();
     $this->cache->setCaching(true);
     $this->cache->setLifeTime($conf->get('cachetime', $lifeTime) * 60);
 }
Example #3
0
 /**
  * A convenience event handler to obtain the text related to an option's 
  * value.
  * 
  * The event cache's the options for quicker lookup and to reduce load on 
  * the database. Therefore, there may be some delay between new items 
  * being added to JReviews and what is retrieved by this event. 
  * 
  * @param string $value The option's value.
  * @return string The text related to the option's value.
  */
 public function onJSolrSearchOptionLookup($value)
 {
     $conf = JFactory::getConfig();
     $options = array('defaultgroup' => 'plg_jsolrsearch_jreviews', 'cachebase' => $conf->getValue('config.cache_path'), 'lifetime' => $conf->getValue('config.cachetime') * 60, 'language' => $conf->getValue('config.language'), 'storage' => $conf->getValue('config.storage', 'file'));
     $cache = new JCache($options);
     $cache->setCaching(true);
     if (!($list = json_decode($cache->get('options', $options['defaultgroup'])))) {
         $database = JFactory::getDbo();
         $query = $database->getQuery(true);
         $query->select(array('text', 'value'))->from('#__jreviews_fieldoptions');
         $database->setQuery($query);
         $list = $database->loadObjectList();
         // cache these options so we don't need to keep loading from db.
         $cache->store(json_encode($list), $options['defaultgroup']);
     }
     $found = false;
     $text = "";
     while (!$found && ($item = current($list))) {
         if ($item->value == $value) {
             $found = true;
             $text = $item->text;
         }
         next($list);
     }
     return $text;
 }
Example #4
0
 /**
  * Constructor.
  *
  * @param	array	An optional associative array of configuration settings.
  * @see		JController
  * @since	1.6
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     //initialize vars
     $this->option = JFactory::getApplication()->input->get('option');
     $this->_comParams = JComponentHelper::getParams($this->option);
     //cache callbacks
     $this->_cache = JCache::getInstance('callback', array('defaultgroup' => $this->option, 'lifetime' => $this->_comParams->get('callback_lifetime', 86400)));
     $this->_cache->setCaching(true);
     //cache request
     $this->_cachePage = JCache::getInstance('output', array('defaultgroup' => $this->option, 'lifetime' => $this->_comParams->get('pages_lifetime', 86400)));
     $this->_cachePage->setCaching(true);
     //load helpers
     $this->loadHelper('document');
     $this->loadHelper('menu');
     $this->loadHelper('url');
 }
Example #5
0
 /**
  * Testing clean().
  *
  * @return void
  */
 public function testClean()
 {
     $options = array('storage' => 'file');
     $this->object = JCache::getInstance('output', $options);
     $this->object->setCaching(true);
     $this->object->store('Now is the time for all good people to throw a party.', 42, '');
     $this->object->store('And this is the cache that tries men\'s souls', 43, '');
     $this->assertThat($this->object->get(43, ''), $this->equalTo('And this is the cache that tries men\'s souls'), 'Should retrieve the data properly');
     $this->assertThat($this->object->clean(''), $this->isTrue(), 'Should remove cached data');
     $this->assertThat($this->object->get(43, ''), $this->isFalse(), 'Should not retrieve the data properly');
     $this->assertThat($this->object->get(42, ''), $this->isFalse(), 'Should not retrieve the data properly');
 }
 /**
  * Testing clean().
  *
  * @return void
  */
 public function testClean()
 {
     $options = array('storage' => 'file');
     $this->object = JCache::getInstance('output', $options);
     $this->object->setCaching(true);
     $this->object->store($this->testData_A, 42, '');
     $this->object->store($this->testData_B, 43, '');
     $this->assertEquals($this->testData_B, $this->object->get(43, ''));
     $this->assertTrue($this->object->clean(''));
     $this->assertFalse($this->object->get(43, ''));
     $this->assertFalse($this->object->get(42, ''));
 }
Example #7
0
 /**
  * TuiyoInitiate::TuiyoInitiate()
  * Application Initiation metod
  * @return
  */
 public function TuiyoInitiate()
 {
     TuiyoInitiate::_setDefines();
     TuiyoInitiate::_loadErrorHandler();
     TuiyoInitiate::_localize();
     jimport('joomla.cache.cache');
     $conf =& JFactory::getConfig();
     $options = array('defaultgroup' => 'com_tuiyo', 'cachebase' => $conf->getValue('config.cache_path'), 'lifetime' => $conf->getValue('config.cachetime') * 60, 'language' => $conf->getValue('config.language'), 'storage' => 'file');
     $cache = new JCache($options);
     $cache->setCaching($conf->getValue('config.caching'));
     $GLOBALS['TUIYO_CACHE'] = $cache;
     //Load the parameters for the site!
     if (class_exists('JSite')) {
         TuiyoInitiate::_params();
     }
     //load all the plugins
     TuiyoInitiate::registerPlugins();
 }
 /**
  * Converting the site URL to fit to the HTTP request.
  *
  * @return  void
  *
  * @since   1.5
  */
 public function onAfterInitialise()
 {
     // Logger::d(__METHOD__);
     global $_PROFILER;
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     if ($app->isAdmin()) {
         return;
     }
     if (count($app->getMessageQueue())) {
         return;
     }
     if ($this->isDisabled()) {
         return;
     }
     if ($user->get('guest') && $app->input->getMethod() == 'GET') {
         $this->_cache->setCaching(true);
     }
 }
 /**
  * Set caching enabled state
  *
  * @param   boolean  $enabled  True to enable caching
  *
  * @return  void
  *
  * @since   11.1
  */
 public function setCaching($enabled)
 {
     $this->cache->setCaching($enabled);
 }