當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ObjectCache::set方法代碼示例

本文整理匯總了PHP中ObjectCache::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP ObjectCache::set方法的具體用法?PHP ObjectCache::set怎麽用?PHP ObjectCache::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ObjectCache的用法示例。


在下文中一共展示了ObjectCache::set方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testSaveData

 /**
  * Tests saving data.
  */
 public function testSaveData()
 {
     $object = $this->saveObject();
     $this->assertSame($object, $this->cache->get(self::CACHE_KEY));
     // Saving using one way
     ObjectCache::set(self::CACHE_KEY, $object);
     $this->assertSame($object, $this->cache->get(self::CACHE_KEY));
     // Saving using the other way
     $this->cache->{self::CACHE_KEY} = $object;
     $this->assertSame($object, $this->cache->get(self::CACHE_KEY));
     $this->cache->clear();
 }
開發者ID:JerryCR,項目名稱:php-2,代碼行數:15,代碼來源:ObjectCacheTest.php

示例2: run

 /**
  * Run query and return array of results
  *
  * @param string $error_message
  * @param boolean $die_on_error
  * @return array
  */
 function run($error_message = '', $die_on_error = true)
 {
     $q = $this->get_query();
     if ($this->cache_lifespan) {
         $cache = new ObjectCache('db_selector_cache_' . get_current_db_connection_name() . '_' . $q, $this->cache_lifespan);
         $results =& $cache->fetch();
         if (false !== $results) {
             return $results;
         }
     }
     $results = array();
     $r = db_query($q, $error_message, $die_on_error);
     if ($r) {
         while ($row = mysql_fetch_array($r, MYSQL_ASSOC)) {
             $results[] = $row;
         }
         mysql_free_result($r);
     }
     if (!empty($cache)) {
         $cache->set($results);
     }
     return $results;
 }
開發者ID:hunter2814,項目名稱:reason_package,代碼行數:30,代碼來源:db_selector.php

示例3: uniqid

 /** @access private */
 function _persist_filename($value, $original = null, $display_name = null)
 {
     $cache_id = uniqid('upload_' . mt_rand() . '_', true);
     $cache = new ObjectCache($cache_id, '360');
     $store = new stdClass();
     $store->value = $value;
     $store->path_to_original = $original;
     $store->display_name = $display_name;
     $cache->set($store);
     return $cache_id;
 }
開發者ID:natepixel,項目名稱:reason_package,代碼行數:12,代碼來源:upload.php

示例4: ObjectCache

 final function create_nonce()
 {
     $nonce_key = md5(uniqid(mt_rand(), true));
     $update_data['config'] = $this->get_config();
     $update_data['model'] = $this->model_name;
     $update = new ObjectCache($nonce_key);
     $update->set($update_data);
     return $nonce_key;
 }
開發者ID:natepixel,項目名稱:SweeterTweetReader,代碼行數:9,代碼來源:abstract.php

示例5: ObjectCache

	function _get_version_info()
	{
		$version = $this->get_current_version_id();
		
		$cache = new ObjectCache();
		$cache->init('ReasonVersionCheckCache', 86400); // cache for 1 day
		$obj = $cache->fetch();
		if(empty($obj) || !$obj->get_data() || $obj->get_version() != $version)
		{
			$obj = new ReasonVersionCheckData;
			$obj->set_data($this->_fetch_response_from_remote_server($version));
			$obj->set_version($version);
			$cache->set($obj);
		}
		return $obj->get_data();
	}
開發者ID:natepixel,項目名稱:reason_package,代碼行數:16,代碼來源:version_check.php

示例6: loadByEmail

 public static function loadByEmail($email)
 {
     $db = Db::instance();
     $query = sprintf("SELECT * FROM user WHERE email = '%s'", $email);
     $result = $db->lookup($query);
     if (!mysql_num_rows($result)) {
         return null;
     } else {
         $row = mysql_fetch_assoc($result);
         $obj = new User($row);
         ObjectCache::set('User', $row['id'], $obj);
         return $obj;
     }
 }
開發者ID:malimu,項目名稱:Pipeline,代碼行數:14,代碼來源:user.class.php

示例7: array

 /**
  * Runs one query for the ES.  If type is empty, it uses the first type by default.
  * This is often called without paramaters in code for front end stuff.
  * <code>
  * $es = new entity_selector( $site_id );
  * $es->add_type( $type_id );
  * $results = $es->run_one();
  * </code>
  * @param int $type type_id (or blank for default)
  * @param string $status Either Live, Pending, Archived, or All ... (optional)
  * @param string $error optional error message
  * @return array
  */
 function run_one($type = '', $status = 'Live', $error = 'run_one error')
 {
     if (!$type) {
         if (isset($this->type[0]) && $this->type[0]) {
             $type = $this->type[0];
         } else {
             trigger_error('Entity Selector: No type available. Try using the method add_type($type_id) before calling run_one(), or call run_one() with the type id as the first argument.');
             return array();
         }
     }
     $query = $this->get_one_query($type, $status);
     $factory =& $this->get_entity_factory();
     if ($this->cache_lifespan) {
         $factory_class = $factory ? get_class($factory) : '';
         //echo '<p>caching '.$this->cache_lifespan.' secs</p>';
         $cache = new ObjectCache('entity_selector_cache_' . get_current_db_connection_name() . '_' . $this->_enable_multivalue_results . '_' . $factory_class . '_' . $query, $this->cache_lifespan);
         $results =& $cache->fetch();
         if (false !== $results) {
             //echo '<p>Cache hit</p>';
             return $results;
         }
         //echo '<p>Cache miss</p>';
     }
     $results = array();
     $r = db_query($query, $this->description . ': ' . $error);
     while ($row = mysql_fetch_array($r, MYSQL_ASSOC)) {
         //pray ($row);
         if ($this->_enable_multivalue_results && isset($results[$row['id']])) {
             $prev_val = $new_val = $key = $val = '';
             $e = $results[$row['id']];
             foreach ($row as $key => $val) {
                 $cur_value = $e->get_value($key);
                 if (is_array($cur_value)) {
                     if (!in_array($val, $cur_value) && !empty($val)) {
                         $cur_value[] = $val;
                         $e->set_value($key, $cur_value);
                     }
                 } elseif ($cur_value != $val && !empty($val)) {
                     if (empty($cur_value)) {
                         $e->set_value($key, $val);
                     } else {
                         $e->set_value($key, array($cur_value, $val));
                     }
                 }
             }
         } else {
             if ($factory) {
                 $e = $factory->get_entity($row);
             } else {
                 $e = new entity($row['id']);
             }
             $e->_values = $row;
         }
         $results[$row['id']] = $e;
     }
     mysql_free_result($r);
     if (!empty($cache)) {
         $cache->set($results);
     }
     return $results;
 }
開發者ID:natepixel,項目名稱:reason_package,代碼行數:74,代碼來源:entity_selector.php


注:本文中的ObjectCache::set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。