示例#1
0
case 'cache':
  if ($var['fsState']=='Stopped') {
    foreach ($disks as $disk) {if ($disk['type']=='Cache') array_offline($disk);}
    echo "<tr class='tr_last'><td><img src='/webGui/images/sum.png' class='icon'>Slots:</td><td colspan='9'>".cache_slots()."</td><td></td></tr>";
    echo "<tr><td colspan='10'></td><td></td></tr>";
  } else {
    foreach ($disks as $disk) {if ($disk['type']=='Cache') array_online($disk);}
    if ($display['total'] && $var['cacheSbNumDisks']>1) show_totals("Pool of ".my_word($var['cacheNumDevices'])." devices");
  }
  break;
case 'open':
  $status = isset($confirm['preclear']) ? '' : '_NP';
  foreach ($devs as $dev) {
    $dev['name'] = 'preclear';
    $dev['color'] = read_disk($dev['device'], 'color');
    $dev['temp'] = read_disk($dev['device'], 'temp');
    $dev['status'] = $status;
    echo "<tr>";
    echo "<td>".device_info($dev)."</td>";
    echo "<td>".device_desc($dev)."</td>";
    echo "<td>".my_temp($dev['temp'])."</td>";
    if (file_exists("/tmp/preclear_stat_{$dev['device']}")) {
      $text = exec("cut -d'|' -f3 /tmp/preclear_stat_{$dev['device']} | sed 's:\^n:\<br\>:g'");
      if (strpos($text,'Total time')===false) $text = 'Preclear in progress... '.$text;
      echo "<td colspan='8' style='text-align:right'><em>$text</em></td>";
    } else
      echo "<td colspan='8'></td>";
    echo "</tr>";
  }
  break;
case 'parity':
示例#2
0
function cache_or_disk($keyword, $backing_file, $cache_keys)
{
    //  fb("cache_or_disk({$keyword}, {$backing_file}, ...");
    //  fb($cache_keys, "cache_keys");
    $known_keywords = array('objects', 'status', 'perms');
    if (!in_array($keyword, $known_keywords)) {
        // XXX do something better
        die("Unknown keyword '{$keyword}'");
    }
    $useAPC = useAPC();
    $start_time = microtime(TRUE);
    $array = NULL;
    //fb($keyword, "doing cache_or_disk($keyword)");
    if ($useAPC) {
        //fb(apc_cache_info(), "apc cache info");
        $read_file = cache_needs_update($keyword, $backing_file);
        $cacheFail = FALSE;
        $success = FALSE;
        if (!$read_file) {
            // Loop through each variables cached value.  If a read fails note it and
            // read from disk
            foreach ($cache_keys as $key) {
                $array[$key] = apc_fetch($key, $success);
                if (!$success) {
                    $cacheFail = TRUE;
                    //fb("Cache Fail for key {$key}!");
                    break;
                }
            }
            if (!$cacheFail) {
                // Every key was found in cache
                //fb("$keyword data from cache!");
            }
        }
    }
    // The cache is not enabled or
    //  the cache is enabled and of the following three conditions occurred
    //  There was a cache miss
    //  The data file is newer than the cached version
    if (!$useAPC || !$success || $read_file || $cacheFail) {
        $array = read_disk($keyword, $cache_keys);
        if ($useAPC) {
            //foreach($cache_keys as $key) {
            foreach (array_keys($array) as $key) {
                apc_store($key, $array[$key]);
            }
            apc_store('last_' . $keyword . '_read', time());
            //fb('stored keys to cache');
        }
        //fb("$keyword data from disk!");
    }
    $end_time = microtime(TRUE);
    //fb($end_time - $start_time, "Elapsed load time {$end_time} - {$start_time}");
    return $array;
}