当前位置: 首页>>代码示例>>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;未经允许,请勿转载。