예제 #1
0
 /**
  * {@inheritdoc}
  */
 protected function doGetStats()
 {
     $info = apcu_cache_info('', true);
     $sma = apcu_sma_info();
     // @TODO - Temporary fix @see https://github.com/krakjoe/apcu/pull/42
     if (PHP_VERSION_ID >= 50500) {
         $info['num_hits'] = isset($info['num_hits']) ? $info['num_hits'] : $info['nhits'];
         $info['num_misses'] = isset($info['num_misses']) ? $info['num_misses'] : $info['nmisses'];
         $info['start_time'] = isset($info['start_time']) ? $info['start_time'] : $info['stime'];
     }
     return array(Cache::STATS_HITS => $info['num_hits'], Cache::STATS_MISSES => $info['num_misses'], Cache::STATS_UPTIME => $info['start_time'], Cache::STATS_MEMORY_USAGE => $info['mem_size'], Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem']);
 }
예제 #2
0
 /**
  * APC preset is available if extension is loaded and at least ~5MB are free.
  *
  * @return bool TRUE
  */
 public function isAvailable()
 {
     $result = false;
     if (extension_loaded('apcu')) {
         $memoryInfo = @apcu_sma_info();
         $availableMemory = $memoryInfo['avail_mem'];
         // If more than 5MB free
         if ($availableMemory > 5 * 1024 * 1024) {
             $result = true;
         }
     }
     return $result;
 }
예제 #3
0
파일: APCu.php 프로젝트: difra-org/difra
 /**
  * Is APCu available?
  * @return bool
  */
 public static function isAvailable()
 {
     try {
         if (!extension_loaded('apcu') or php_sapi_name() == 'cli' or !function_exists('apcu_sma_info')) {
             return false;
         }
         $info = @apcu_sma_info(true);
         if ($e = error_get_last() and $e['file'] == __FILE__) {
             return false;
         }
         if (empty($info) or empty($info['num_seg'])) {
             return false;
         }
     } catch (\Exception $ex) {
         return false;
     }
     return true;
 }
예제 #4
0
파일: apc.php 프로젝트: bitweaver/kernel
        }
    }
}
// clear cache
if ($AUTHENTICATED && isset($MYREQUEST['CC']) && $MYREQUEST['CC']) {
    apcu_clear_cache();
}
if ($AUTHENTICATED && !empty($MYREQUEST['DU'])) {
    apcu_delete($MYREQUEST['DU']);
}
if (!function_exists('apcu_cache_info')) {
    echo "No cache info available.  APC does not appear to be running.";
    exit;
}
$cache = apcu_cache_info();
$mem = apcu_sma_info();
// don't cache this page
//
header("Cache-Control: no-store, no-cache, must-revalidate");
// HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
// HTTP/1.0
function duration($ts)
{
    global $time;
    $years = (int) (($time - $ts) / (7 * 86400) / 52.177457);
    $rem = (int) ($time - $ts - $years * 52.177457 * 7 * 86400);
    $weeks = (int) ($rem / (7 * 86400));
    $days = (int) ($rem / 86400) - $weeks * 7;
    $hours = (int) ($rem / 3600) - $days * 24 - $weeks * 7 * 24;
예제 #5
0
 /**
  * Get available space in bytes
  *
  * @return int|float
  */
 public function getAvailableSpace()
 {
     $smaInfo = apcu_sma_info(true);
     return $smaInfo['avail_mem'];
 }
예제 #6
0
파일: index.php 프로젝트: ovr/apc-dashboard
        return apc_sma_info($limited);
    }
    /**
     * @param string $type
     * @param bool $limited
     * @return array|bool Array of cached data (and meta-data) or FALSE on failure.
     */
    function apcu_cache_info($type = '', $limited = false)
    {
        return apc_cache_info($type, $limited);
    }
    class APCUIterator extends APCIterator
    {
    }
}
$smaInfo = apcu_sma_info();
$cacheInfo = apcu_cache_info();
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <table>
        <tr>
            <td colspan="2">
               <h2>Cache Information</h2>
            </td>
예제 #7
0
 function apc_sma_info($limited = false)
 {
     return apcu_sma_info($limited);
 }
예제 #8
0
 /**
  * {@inheritdoc}
  */
 protected function doGetStats()
 {
     $info = apcu_cache_info(true);
     $sma = apcu_sma_info();
     return array(Cache::STATS_HITS => $info['num_hits'], Cache::STATS_MISSES => $info['num_misses'], Cache::STATS_UPTIME => $info['start_time'], Cache::STATS_MEMORY_USAGE => $info['mem_size'], Cache::STATS_MEMORY_AVAILABLE => $sma['avail_mem']);
 }
예제 #9
0
 public function getFillingPercentage()
 {
     if (php_sapi_name() == 'cli') {
         return 0;
     }
     $mem = apcu_sma_info(true);
     $memSize = $mem['num_seg'] * $mem['seg_size'];
     $memAvailable = $mem['avail_mem'];
     $memUsed = $memSize - $memAvailable;
     if ($memSize == 0) {
         Zend_Cache::throwException('can\'t get apc memory size');
     }
     if ($memUsed > $memSize) {
         return 100;
     }
     return (int) (100.0 * ($memUsed / $memSize));
 }
예제 #10
0
 public static function handleCacheRequest()
 {
     $GLOBALS['Session']->requireAccountLevel('Staff');
     $memInfo = apcu_sma_info(true);
     return static::respond('cacheStatus', ['free' => $memInfo['avail_mem'], 'responses' => Cache::getIterator('/^response:/')->getTotalSize(), 'total' => $memInfo['seg_size']]);
 }
예제 #11
0
 /**
  * APCu sma info
  * @param \Slim\Http\Request $req http request
  * @param \Slim\Http\Response $res http response
  */
 public function info(Request $req, Response $res)
 {
     return $res->withStatus(200)->withHeader('Content-type', 'application/json')->write(json_encode(apcu_sma_info(), JSON_PRETTY_PRINT));
 }