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


PHP JCache::store方法代码示例

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


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

示例1: getTableSchema

 /**
  * Retrieves the table schema information about the given table
  *
  * This function try to get the table schema from the cache. If it cannot be found the table schema will be
  * retrieved from the database and stored in the cache.
  *
  * @param   string  $table A table name or a list of table names
  * @return  KDatabaseSchemaTable
  */
 public function getTableSchema($table)
 {
     if (!isset($this->_table_schema[$table]) && isset($this->_cache)) {
         $identifier = md5($this->getDatabase() . $table);
         if (!($schema = $this->_cache->get($identifier))) {
             $schema = parent::getTableSchema($table);
             //Store the object in the cache
             $this->_cache->store(serialize($schema), $identifier);
         } else {
             $schema = unserialize($schema);
         }
         $this->_table_schema[$table] = $schema;
     }
     return parent::getTableSchema($table);
 }
开发者ID:daodaoliang,项目名称:nooku-framework,代码行数:24,代码来源:mysqli.php

示例2: _parse

 /**
  * Parse the template
  *
  * This function implements a caching mechanism when reading the template. If the template cannot be found in the
  * cache it will be filtered and stored in the cache. Otherwise it will be loaded from the cache and returned
  * directly.
  *
  * @param string The template content to parse
  * @return void
  */
 protected function _parse(&$content)
 {
     if (isset($this->_cache)) {
         $identifier = md5($this->getPath());
         if (!$this->_cache->get($identifier)) {
             parent::_parse($content);
             //Store the object in the cache
             $this->_cache->store($content, $identifier);
         } else {
             $content = $this->_cache->get($identifier);
         }
     } else {
         parent::_parse($content);
     }
 }
开发者ID:janssit,项目名称:nickys.janss.be,代码行数:25,代码来源:default.php

示例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;
 }
开发者ID:bellodox,项目名称:jsolr,代码行数:37,代码来源:jreviews.php

示例4: testGc

	/**
	 * Testing Gc().
	 *
	 * @return void
	 */
	public function testGc()
	{
		$this->object = JCache::getInstance('output', array('lifetime' => 2, 'defaultgroup' => ''));
		$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',
			42,
			''
		);
		sleep(5);
		$this->object->gc();
		$this->assertThat(
			$this->object->get(42, ''),
			$this->isFalse(),
			'Should not retrieve the data properly'
		);
		$this->assertThat(
			$this->object->get(42, ''),
			$this->isFalse(),
			'Should not retrieve the data properly'
		);
	}
开发者ID:realityking,项目名称:joomla-platform,代码行数:31,代码来源:JCacheTest.php

示例5: testGc

 /**
  * Testing Gc().
  *
  * @medium
  *
  * @return void
  */
 public function testGc()
 {
     $this->object = JCache::getInstance('output', array('lifetime' => 2, 'defaultgroup' => ''));
     $this->object->store($this->testData_A, 42, '');
     $this->object->store($this->testData_B, 43, '');
     sleep(5);
     $this->object->gc();
     $this->assertFalse($this->object->get(42, ''));
     $this->assertFalse($this->object->get(43, ''));
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:17,代码来源:JCacheTest.php

示例6: save

 function save($content, $id)
 {
     // Store the cache string
     for ($i = 0; $i < 5; $i++) {
         if (parent::store(serialize($content), $id)) {
             return;
         }
     }
     parent::remove($id);
 }
开发者ID:affiliatelk,项目名称:ecc,代码行数:10,代码来源:cache.php

示例7: store

 /**
  * Store data to cache by ID and group
  *
  * @param   mixed    $data        The data to store
  * @param   string   $id          The cache data ID
  * @param   string   $group       The cache data group
  * @param   boolean  $wrkarounds  True to use wrkarounds
  *
  * @return  boolean  True if cache stored
  *
  * @since   11.1
  */
 public function store($data, $id, $group = null, $wrkarounds = true)
 {
     $locktest = $this->cache->lock($id, $group);
     if ($locktest->locked == false && $locktest->locklooped == true) {
         $locktest = $this->cache->lock($id, $group);
     }
     $success = $this->cache->store(serialize($data), $id, $group);
     if ($locktest->locked == true) {
         $this->cache->unlock($id, $group);
     }
     return $success;
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:24,代码来源:controller.php

示例8: parse

 /**
  * Parse the template
  * 
  * This function implements a caching mechanism when reading the template. If
  * the tempplate cannot be found in the cache it will be filtered and stored in
  * the cache. Otherwise it will be loaded from the cache and returned directly.
  *
  * @return string	The filtered data
  */
 public function parse()
 {
     if (isset($this->_cache)) {
         $identifier = md5($this->_path);
         if (!($template = $this->_cache->get($identifier))) {
             $template = parent::parse();
             //Store the object in the cache
             $this->_cache->store($template, $identifier);
         }
         return $template;
     }
     return parent::parse();
 }
开发者ID:raeldc,项目名称:nooku-server,代码行数:22,代码来源:abstract.php

示例9: store

 /**
  * Stop the cache buffer and store the cached data
  *
  * @access	public
  * @return	boolean	True if cache stored
  * @since	1.5
  */
 function store()
 {
     // Get page data from JResponse body
     $data = JResponse::getBody();
     // Get id and group and reset them placeholders
     $id = $this->_id;
     $group = $this->_group;
     $this->_id = null;
     $this->_group = null;
     // Only attempt to store if page data exists
     if ($data) {
         return parent::store($data, $id, $group);
     }
     return false;
 }
开发者ID:RangerWalt,项目名称:ecci,代码行数:22,代码来源:page.php

示例10: store

 /**
  * Store data to cache by id and group
  *
  * @param   mixed   $data   The data to store
  * @param   string  $id     The cache data id
  * @param   string  $group  The cache data group
  *
  * @return  boolean  True if cache was stored
  *
  * @since   11.1
  */
 public function store($data, $id, $group = null)
 {
     $locktest = new stdClass();
     $locktest->locked = null;
     $locktest->locklooped = null;
     $locktest = $this->cache->lock($id, $group);
     if ($locktest->locked == false && $locktest->locklooped == true) {
         $locktest = $this->cache->lock($id, $group);
     }
     $sucess = $this->cache->store(serialize($data), $id, $group);
     if ($locktest->locked == true) {
         $this->cache->unlock($id, $group);
     }
     return $sucess;
 }
开发者ID:jimyb3,项目名称:mathematicalteachingsite,代码行数:26,代码来源:controller.php

示例11: onAfterRender

 /**
  * After render.
  *
  * @return   void
  *
  * @since   1.5
  */
 public function onAfterRender()
 {
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         return;
     }
     if (count($app->getMessageQueue())) {
         return;
     }
     if ($this->isDisabled()) {
         return;
     }
     $user = JFactory::getUser();
     if ($user->get('guest') && $app->input->getMethod() == 'GET') {
         $this->_cache->store($this->optimize($app->getBody()), $this->_cache_key);
     }
 }
开发者ID:rustyJ4ck,项目名称:joomla-page-cache,代码行数:24,代码来源:cache.new.php

示例12: 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

示例13: checkSignupApiField

 private function checkSignupApiField($MC, $listId)
 {
     // create hidden signup date mergevar if it doesn't exist
     $cacheGroup = 'mod_mailchimpsignup';
     $cacheID = 'SIGNUPAPI_' . $listId;
     jimport('joomla.cache.cache');
     $cacheOptions = array();
     $cacheOptions['lifetime'] = 525949;
     $cacheOptions['defaultgroup'] = $cacheGroup;
     $cacheOptions['caching'] = true;
     $cache = new JCache($cacheOptions);
     if (!$cache->get($cacheID, $cacheGroup)) {
         $createSignupdateMerge = true;
         $listMergeVars = $MC->listMergeVars($listId);
         foreach ($listMergeVars as $lmv) {
             if ($lmv['tag'] == 'SIGNUPAPI') {
                 $createSignupdateMerge = false;
                 break;
             }
         }
         if ($createSignupdateMerge) {
             $MC->listMergeVarAdd($listId, 'SIGNUPAPI', 'date added (API)', array('field_type' => 'date', 'req' => false, 'public' => false, 'show' => true));
         }
         $cache->store(true, $cacheID, $cacheGroup);
     }
 }
开发者ID:rodhoff,项目名称:MNW,代码行数:26,代码来源:controller.php

示例14: load

 /**
  * Loads a single language file and appends the results to the existing strings
  *
  * @access	public
  * @param	string 	$extension 	The extension for which a language file should be loaded
  * @param	string 	$basePath  	The basepath to use
  * @param	string	$lang		The language to load, default null for the current language
  * @param	boolean $reload		Flag that will force a language to be reloaded if set to true
  * @return	boolean	True, if the file has successfully loaded.
  * @since	1.5
  */
 function load($extension = 'joomla', $basePath = JPATH_BASE, $lang = null, $reload = false)
 {
     if (!$lang) {
         $lang = $this->_lang;
     }
     if (!strlen($extension)) {
         $extension = 'joomla';
     }
     $path = JLanguage::getLanguagePath($basePath, $lang);
     $filename = $extension == 'joomla' ? $lang : $lang . '.' . $extension;
     $filename = $path . DS . $filename . '.ini';
     $result = true;
     if (!isset($this->_paths[$extension][$filename]) || $reload) {
         $identifier = md5($extension . $basePath . $lang);
         if (!isset($this->_cache)) {
             $this->_cache = JFactory::getCache('language', 'output');
         }
         if (!($data = $this->_cache->get($identifier))) {
             // Load the language file
             $strings = $this->_load($filename, $extension, true);
             // Check if there was a problem with loading the file
             if ($strings === false) {
                 // No strings, which probably means that the language file does not exist
                 $path = JLanguage::getLanguagePath($basePath, $this->_default);
                 $filename = $extension == 'joomla' ? $this->_default : $this->_default . '.' . $extension;
                 $filename = $path . DS . $filename . '.ini';
                 $strings = $this->_load($filename, $extension, false);
                 if ($strings !== false) {
                     $this->_strings = array_merge($strings, $this->_strings);
                 }
             } else {
                 $this->_strings = array_merge($this->_strings, (array) $strings);
             }
             //Store the strings in the cache
             if ($strings !== false) {
                 $this->_cache->store(serialize($strings), $identifier);
             }
         } else {
             $this->_strings = array_merge($this->_strings, array_reverse(unserialize($data)));
         }
     }
     return $result;
 }
开发者ID:JSWebdesign,项目名称:intranet-platform,代码行数:54,代码来源:language.php

示例15: storeFileInfo

 /**
  * @param RokBooster_Compressor_FileGroup $group
  */
 protected function storeFileInfo(RokBooster_Compressor_FileGroup $group)
 {
     $group->cleanup();
     $this->file_info_cache->store(serialize($group), $group->getChecksum() . '_fileinfo');
 }
开发者ID:rogatnev-nikita,项目名称:cloudinterpreter,代码行数:8,代码来源:AbstractStrategy.php


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