本文整理汇总了PHP中JCache::setCaching方法的典型用法代码示例。如果您正苦于以下问题:PHP JCache::setCaching方法的具体用法?PHP JCache::setCaching怎么用?PHP JCache::setCaching使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JCache
的用法示例。
在下文中一共展示了JCache::setCaching方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
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);
}
示例2: __construct
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);
}
示例3: onJSolrSearchOptionLookup
/**
* 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;
}
示例4: __construct
/**
* 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');
}
示例5: testClean
/**
* 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');
}
示例6: testClean
/**
* 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, ''));
}
示例7: TuiyoInitiate
/**
* 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();
}
示例8: onAfterInitialise
/**
* 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);
}
}
示例9: setCaching
/**
* Set caching enabled state
*
* @param boolean $enabled True to enable caching
*
* @return void
*
* @since 11.1
*/
public function setCaching($enabled)
{
$this->cache->setCaching($enabled);
}