本文整理汇总了PHP中ObjectCache::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectCache::fetch方法的具体用法?PHP ObjectCache::fetch怎么用?PHP ObjectCache::fetch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectCache
的用法示例。
在下文中一共展示了ObjectCache::fetch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: ObjectCache
/** @access private */
function _restore_filename($cache_id)
{
$cache = new ObjectCache($cache_id, '360');
$store =& $cache->fetch();
if (!$store) {
return array(null, null, null);
}
return array($store->value, $store->path_to_original, $store->display_name);
}
示例3: ObjectCache
/**
* Using the data_id, retrieve the data from our local cache
*/
final function get_local_data()
{
$id = $this->get_data_id();
$cache = new ObjectCache($id, 999999999);
// we use an enormous expiration ... we want to get whatever exists.
$data =& $cache->fetch();
return $data;
}
示例4: SweeterTweetReader
<?php
/**
* The sweeter tweet reader agent handles the background requests when given a proper nonce.
*/
require_once '../sweeter_tweet_reader.php';
if (isset($_REQUEST['sweeter_tweet_reader_nonce'])) {
// retrieve the model and config from the nonce
$sweet_tweet = new SweeterTweetReader();
$update = new ObjectCache($_REQUEST['sweeter_tweet_reader_nonce'], 999999999);
$data = $update->fetch();
if (!empty($data)) {
$sweet_tweet->set($data['model']);
$sweet_tweet->config($data['config']);
$sweet_tweet->update();
}
$update->clear();
}
示例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();
}
示例6: 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;
}