当前位置: 首页>>代码示例>>PHP>>正文


PHP JCache::setLifeTime方法代码示例

本文整理汇总了PHP中JCache::setLifeTime方法的典型用法代码示例。如果您正苦于以下问题:PHP JCache::setLifeTime方法的具体用法?PHP JCache::setLifeTime怎么用?PHP JCache::setLifeTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JCache的用法示例。


在下文中一共展示了JCache::setLifeTime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSetLifeTime

	/**
	 * Testing setLifeTime
	 *
	 * @param   string   $handler   cache handler
	 * @param   array    $options   options for cache handler
	 * @param   integer  $lifetime  lifetime of cache to be set
	 *
	 * @return void
	 *
	 * @dataProvider casesSetLifetime
	 */
	public function testSetLifeTime($handler, $options, $lifetime)
	{
		$this->object = JCache::getInstance($handler, $options);
		$this->object->setLifeTime($lifetime);
		$this->assertThat(
			$this->object->options['lifetime'],
			$this->equalTo($lifetime)
		);
	}
开发者ID:realityking,项目名称:joomla-platform,代码行数:20,代码来源:JCacheTest.php

示例2: fetchXML

 static function fetchXML($params, $force = 0)
 {
     $rssurl = $params->get('rss_url', '');
     $items_limit = intval($params->get('items_limit', 10));
     $doCache = intval($params->get('scr_cache', 1));
     $CacheTime = intval($params->get('cache_time', 3600));
     $twitter_timeline = $params->get('twitter_timeline', 'user');
     $username = $params->get('twitter_username', '');
     $password = $params->get('twitter_password', '');
     $list = $params->get('twitter_list', '');
     if ($twitter_timeline == 'friends') {
         $rssurl = 'http://api.twitter.com/1/statuses/friends_timeline.xml';
     } else {
         if ($twitter_timeline == 'mentions') {
             $rssurl = 'http://api.twitter.com/1/statuses/mentions.xml';
         } else {
             if ($twitter_timeline == 'list') {
                 $rssurl = 'http://api.twitter.com/1/' . urlencode($username) . '/lists/' . urlencode($list) . '/statuses.xml';
             } else {
                 if ($twitter_timeline == 'user_rt' && $username != '') {
                     $rssurl = 'http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=' . urlencode($username) . '&include_rts=true';
                 } else {
                     if ($username != '') {
                         $rssurl = 'http://api.twitter.com/1/statuses/user_timeline/' . urlencode($username) . '.xml';
                     } else {
                         $rssurl = str_replace('.rss', '.xml', $rssurl);
                     }
                 }
             }
         }
     }
     $feed_desc = 1;
     $item_desc = 1;
     $feed_array = array();
     $xmlDoc =& JFactory::getXMLParser('Simple');
     if ($doCache) {
         if (!class_exists('JCache')) {
             require_once JPATH_SITE . DS . 'libraries' . DS . 'joomla' . DS . 'cache' . DS . 'cache.php';
         }
         $options = array('defaultgroup' => 'mod_ajaxscroller', 'lifetime' => $CacheTime, 'checkTime' => true, 'caching' => true);
         $cache = new JCache($options);
         $cache->setLifeTime($CacheTime);
         if ($force) {
             // delete the cache, force the new fetch
             $cache->remove(md5($rssurl), 'mod_ajaxscroller');
         }
         if ($string = $cache->get(md5($rssurl), 'mod_ajaxscroller')) {
             $xmlDoc->loadString($string);
         } else {
             $xml = simplexml_load_file($rssurl);
             $string = $xml->asXML();
             $string = str_replace('georss:', 'georss_', $string);
             // simplexml doesn't like ':'
             $xmlDoc->loadString($string);
             $cache->store($xmlDoc->document->toString(), md5($rssurl));
         }
     } else {
         $xml = simplexml_load_file($rssurl);
         $string = $xml->asXML();
         $string = str_replace('georss:', 'georss_', $string);
         // simplexml doesn't like ':'
         $xmlDoc->loadString($string);
     }
     $root =& $xmlDoc->document;
     $statuses =& $root->children();
     $length = count($statuses);
     $total = $items_limit && $items_limit < $length ? $items_limit : $length;
     if ($total == 0) {
         $feed_array = $xmlDoc->loadString($string);
     }
     for ($i = 0; $i < $total; $i++) {
         $status =& $statuses[$i];
         $id =& $status->getElementByPath('id')->data();
         $created_at =& $status->getElementByPath('created_at')->data();
         $text =& $status->getElementByPath('text')->data();
         $source =& $status->getElementByPath('source')->data();
         $in_reply_to_status_id =& $status->getElementByPath('in_reply_to_status_id')->data();
         $in_reply_to_user_id =& $status->getElementByPath('in_reply_to_user_id')->data();
         $in_reply_to_screen_name =& $status->getElementByPath('in_reply_to_screen_name')->data();
         $user_id =& $status->getElementByPath('user')->getElementByPath('id')->data();
         $user_screen_name =& $status->getElementByPath('user')->getElementByPath('screen_name')->data();
         $user_profile_image_url =& $status->getElementByPath('user')->getElementByPath('profile_image_url')->data();
         $feed_array[$i]['item_href'] = 'http://twitter.com/' . $user_screen_name . '/statuses/' . $id;
         $feed_array[$i]['item_date'] = $created_at;
         $feed_array[$i]['item_title'] = $user_screen_name;
         //$text = htmlentities($text);
         $feed_array[$i]['item_desc'] = modAjaxScrollerCommonHelper::ajax_scroller_format_twitter($text, $params, $user_profile_image_url, $user_screen_name, $created_at, $source, $in_reply_to_user_id, $in_reply_to_screen_name, $in_reply_to_status_id);
     }
     return $feed_array;
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:90,代码来源:twitter.php

示例3: setLifeTime

 /**
  * Sets the lifetime of the cache
  *
  * @abstract
  *
  * @param  int $lifeTime Lifetime of the cache
  *
  * @return void
  */
 public function setLifeTime($lifeTime)
 {
     $this->lifeTime = $lifeTime;
     $this->cache->setLifeTime($this->lifeTime);
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:14,代码来源:joomlaCacheDriver.class.php

示例4: setLifeTime

 /**
  * Set cache lifetime
  *
  * @param   integer  $lt  Cache lifetime
  *
  * @return  void
  *
  * @since   11.1
  */
 public function setLifeTime($lt)
 {
     $this->cache->setLifeTime($lt);
 }
开发者ID:jimyb3,项目名称:mathematicalteachingsite,代码行数:13,代码来源:controller.php


注:本文中的JCache::setLifeTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。