本文整理汇总了PHP中pts_openbenchmarking::openbenchmarking_index_refreshed方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_openbenchmarking::openbenchmarking_index_refreshed方法的具体用法?PHP pts_openbenchmarking::openbenchmarking_index_refreshed怎么用?PHP pts_openbenchmarking::openbenchmarking_index_refreshed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_openbenchmarking
的用法示例。
在下文中一共展示了pts_openbenchmarking::openbenchmarking_index_refreshed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: refresh_repository_lists
public static function refresh_repository_lists($repos = null, $force_refresh = false)
{
if ($repos == null) {
if ($force_refresh == false) {
if (!defined('HAS_REFRESHED_OBO_LIST')) {
pts_define('HAS_REFRESHED_OBO_LIST', true);
} else {
return true;
}
}
$repos = self::linked_repositories();
}
foreach ($repos as $repo_name) {
pts_file_io::mkdir(PTS_OPENBENCHMARKING_SCRATCH_PATH . $repo_name);
if ($repo_name == 'local') {
// Local is a special case, not actually a real repository
continue;
}
if (!is_dir(PTS_OPENBENCHMARKING_SCRATCH_PATH . $repo_name)) {
mkdir(PTS_OPENBENCHMARKING_SCRATCH_PATH . $repo_name, 0777, true);
}
$index_file = PTS_OPENBENCHMARKING_SCRATCH_PATH . $repo_name . '.index';
$server_index = null;
if (is_file($index_file)) {
$repo_index = json_decode(file_get_contents($index_file), true);
$generated_time = $repo_index['main']['generated'];
// Refreshing the indexes once every few days should be suffice
// Refresh approximately every three days by default
$index_cache_ttl = 3;
if (PTS_IS_CLIENT && ($config_ttl = pts_config::read_user_config('PhoronixTestSuite/Options/OpenBenchmarking/IndexCacheTTL'))) {
if ($config_ttl === 0) {
// if the value is 0, only rely upon manual refreshes
continue;
} else {
if (is_numeric($config_ttl) && $config_ttl >= 1) {
$index_cache_ttl = $config_ttl;
}
}
}
if ($generated_time > time() - 86400 * $index_cache_ttl && $force_refresh == false && (!defined('FIRST_RUN_ON_PTS_UPGRADE') || FIRST_RUN_ON_PTS_UPGRADE == false)) {
// The index is new enough
continue;
}
if (pts_network::internet_support_available()) {
$server_index = pts_openbenchmarking::make_openbenchmarking_request('repo_index', array('repo' => $repo_name));
self::$openbenchmarking_index_refreshed = true;
}
if (!$server_index && ($phoromatic_cache_index = self::phoromatic_server_ob_cache_request('index', $repo_name))) {
// Ensure the Phoromatic cache has a newer version of the index than what's currently on the system
$repo_index = json_decode($phoromatic_cache_index, true);
if (isset($repo_index['main']['generated'])) {
$cache_generated_time = $repo_index['main']['generated'];
if ($cache_generated_time > $generated_time) {
$server_index = $phoromatic_cache_index;
}
self::$openbenchmarking_index_refreshed = true;
}
}
} else {
if (pts_network::internet_support_available()) {
$server_index = pts_openbenchmarking::make_openbenchmarking_request('repo_index', array('repo' => $repo_name));
self::$openbenchmarking_index_refreshed = true;
}
}
if (!$server_index && ($phoromatic_cache_index = self::phoromatic_server_ob_cache_request('index', $repo_name))) {
$server_index = $phoromatic_cache_index;
}
if ($server_index != null && json_decode($server_index) != false) {
file_put_contents($index_file, $server_index);
} else {
if (PTS_IS_CLIENT && is_file('/var/cache/phoronix-test-suite/openbenchmarking.org/' . $repo_name . '.index')) {
copy('/var/cache/phoronix-test-suite/openbenchmarking.org/' . $repo_name . '.index', $index_file);
}
}
if (!is_file($index_file)) {
static $reported_read_failure_notice;
if (!isset($reported_read_failure_notice[$repo_name]) && PTS_IS_CLIENT) {
trigger_error('Failed To Fetch OpenBenchmarking.org Repository Data: ' . $repo_name, E_USER_WARNING);
$reported_read_failure_notice[$repo_name] = true;
}
}
}
}