本文整理汇总了PHP中xcache_info函数的典型用法代码示例。如果您正苦于以下问题:PHP xcache_info函数的具体用法?PHP xcache_info怎么用?PHP xcache_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xcache_info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: status
/**
* @inheritdoc
*/
public function status()
{
$info = xcache_info(XC_TYPE_VAR, 0);
$status[self::HITS] = isset($info['hits']) ? $info['hits'] : 0;
$status[self::MISSES] = isset($info['misses']) ? $info['misses'] : 0;
$status[self::START_TIME] = 0;
$status[self::MEMORY_USED] = isset($info['size']) ? $info['size'] : 0;
$status[self::MEMORY_LEFT] = isset($info['avail']) ? $info['avail'] : 0;
return $status;
}
示例2: getCacheInfos
function getCacheInfos()
{
$phpCacheCount = xcache_count(XC_TYPE_PHP);
$varCacheCount = xcache_count(XC_TYPE_VAR);
$cacheInfos = array();
for ($i = 0; $i < $phpCacheCount; $i++) {
$cacheInfo = xcache_info(XC_TYPE_PHP, $i);
$cacheInfo['type'] = XC_TYPE_PHP;
$cacheInfos[] = $cacheInfo;
}
for ($i = 0; $i < $varCacheCount; $i++) {
$cacheInfo = xcache_info(XC_TYPE_VAR, $i);
$cacheInfo['type'] = XC_TYPE_VAR;
$cacheInfos[] = $cacheInfo;
}
return $cacheInfos;
}
示例3: get_data
function get_data()
{
$pcnt = xcache_count(XC_TYPE_PHP);
$vcnt = xcache_count(XC_TYPE_VAR);
$info['php_max'] = 0;
$info['php_cur'] = 0;
$info['var_max'] = 0;
$info['var_cur'] = 0;
$info['php_hits'] = 0;
$info['var_hits'] = 0;
$info['php_miss'] = 0;
$info['var_miss'] = 0;
$info['php_cached'] = 0;
$info['var_cached'] = 0;
$info['php_errors'] = 0;
$info['var_errors'] = 0;
$cacheInfos = array();
for ($i = 0; $i < $pcnt; $i++) {
$data = xcache_info(XC_TYPE_PHP, $i);
$info['php_max'] += $data["size"];
$info['php_cur'] += $data["avail"];
$info['php_hits'] += $data["hits"];
$info['php_miss'] += $data["misses"];
$info['php_cached'] += $data["cached"];
$info['php_errors'] += $data["errors"];
}
for ($i = 0; $i < $vcnt; $i++) {
$data = xcache_info(XC_TYPE_VAR, $i);
$info['var_max'] += $data["size"];
$info['var_cur'] += $data["avail"];
$info['var_hits'] += $data["hits"];
$info['var_miss'] += $data["misses"];
$info['var_cached'] += $data["cached"];
$info['var_errors'] += $data["errors"];
}
return $info;
}
示例4: getStats
/**
* @return driverStatistic
*/
public function getStats()
{
if (!ini_get('xcache.admin.enable_auth')) {
$info = xcache_info(XC_TYPE_VAR, 0);
return (new driverStatistic())->setSize(abs($info['size'] - $info['avail']))->setData(implode(', ', array_keys($this->itemInstances)))->setInfo(sprintf("Xcache v%s with following modules loaded:\n %s", XCACHE_VERSION, str_replace(' ', ', ', XCACHE_MODULES)))->setRawData($info);
} else {
throw new \RuntimeException("PhpFastCache is not able to read Xcache configuration. Please put this to your php.ini:\n\n [xcache.admin]\n xcache.admin.enable_auth = Off\n\n Then reboot your webserver and make sure that the native Xcache ini configuration file does not override your setting.");
}
}
示例5: doGetStats
/**
* {@inheritdoc}
*/
protected function doGetStats()
{
$this->checkAuthorization();
$info = xcache_info(XC_TYPE_VAR, 0);
return array(Cache::STATS_HITS => $info['hits'], Cache::STATS_MISSES => $info['misses'], Cache::STATS_UPTIME => null, Cache::STATS_MEMORY_USAGE => $info['size'], Cache::STATS_MEMORY_AVAILIABLE => $info['avail']);
}
示例6: stats
/**
*/
function stats()
{
if (!$this->is_ready()) {
return null;
}
if (!$this->_check_xcache_auth()) {
return null;
}
$info = xcache_info(XC_TYPE_VAR, 0);
return ['hits' => $info['hits'], 'misses' => $info['misses'], 'uptime' => null, 'mem_usage' => $info['size'], 'mem_avail' => $info['avail']];
}
示例7: getAvailableSpace
/**
* Get available space in bytes
*
* @return int|float
*/
public function getAvailableSpace()
{
$availableSpace = 0;
$this->initAdminAuth();
$cnt = xcache_count(XC_TYPE_VAR);
for ($i = 0; $i < $cnt; $i++) {
$info = xcache_info(XC_TYPE_VAR, $i);
$availableSpace += $info['avail'];
}
$this->resetAdminAuth();
return $availableSpace;
}
示例8: array
if (!$hit_total) {
// cheat for chart after cache clear
$hit_total = 1;
$cache['num_misses'] = 1;
}
$stat_flag = 'apc.stat';
$opcode_stats = array('memory_used' => ($mem_total - $sma['avail_mem']) / $mem_total, 'memory_avail' => $sma['avail_mem'] / $mem_total, 'memory_total' => $mem_total, 'hit_hit' => $cache['num_hits'] / $hit_total, 'hit_miss' => $cache['num_misses'] / $hit_total, 'hit_total' => $hit_total, 'type' => 'apc');
} elseif (function_exists('xcache_info') && (ini_get('xcache.cacher') == '1' || ini_get('xcache.cacher') == 'On')) {
$opcode_cache = 'XCache';
if (ini_get('xcache.admin.enable_auth') == '1' || ini_get('xcache.admin.enable_auth') == 'On') {
$opcode_stats['warning_xcache_blocked'] = true;
} else {
$stat_flag = 'xcache.stat';
$opcode_stats = array('memory_used' => 0, 'memory_avail' => 0, 'memory_total' => 0, 'hit_hit' => 0, 'hit_miss' => 0, 'hit_total' => 0, 'type' => 'xcache');
foreach (range(0, xcache_count(XC_TYPE_PHP) - 1) as $index) {
$info = xcache_info(XC_TYPE_PHP, $index);
$opcode_stats['hit_hit'] += $info['hits'];
$opcode_stats['hit_miss'] += $info['misses'];
$opcode_stats['hit_total'] += $info['hits'] + $info['misses'];
$opcode_stats['memory_used'] += $info['size'] - $info['avail'];
$opcode_stats['memory_avail'] += $info['avail'];
$opcode_stats['memory_total'] += $info['size'];
}
$opcode_stats['memory_used'] /= $opcode_stats['memory_total'];
$opcode_stats['memory_avail'] /= $opcode_stats['memory_total'];
$opcode_stats['hit_hit'] /= $opcode_stats['hit_total'];
$opcode_stats['hit_miss'] /= $opcode_stats['hit_total'];
}
} elseif (function_exists('wincache_ocache_fileinfo') && ini_get('wincache.ocenabled') == '1') {
$opcode_cache = 'WinCache';
$stat_flag = 'wincache.ocenabled';
示例9: getOpcodeCacheStatus
public function getOpcodeCacheStatus()
{
$opcode_stats = array('opcode_cache' => null, 'stat_flag' => null, 'warning_check' => false, 'warning_fresh' => false, 'warning_ratio' => false, 'warning_starve' => false, 'warning_low' => false, 'warning_xcache_blocked' => false);
if (function_exists('apc_sma_info') && ini_get('apc.enabled')) {
if ($_REQUEST['apc_clear']) {
check_ticket('admin-inc-performance');
apc_clear_cache();
apc_clear_cache('user');
apc_clear_cache('opcode');
}
$sma = apc_sma_info();
$mem_total = $sma['num_seg'] * $sma['seg_size'];
$cache = apc_cache_info(null, true);
$hit_total = $cache['num_hits'] + $cache['num_misses'];
if (!$hit_total) {
// cheat for chart after cache clear
$hit_total = 1;
$cache['num_misses'] = 1;
}
$opcode_stats = array('opcode_cache' => 'APC', 'stat_flag' => 'apc.stat', 'memory_used' => ($mem_total - $sma['avail_mem']) / $mem_total, 'memory_avail' => $sma['avail_mem'] / $mem_total, 'memory_total' => $mem_total, 'hit_hit' => $cache['num_hits'] / $hit_total, 'hit_miss' => $cache['num_misses'] / $hit_total, 'hit_total' => $hit_total, 'type' => 'apc');
} elseif (function_exists('xcache_info') && (ini_get('xcache.cacher') == '1' || ini_get('xcache.cacher') == 'On')) {
if (ini_get('xcache.admin.enable_auth') == '1' || ini_get('xcache.admin.enable_auth') == 'On') {
$opcode_stats['warning_xcache_blocked'] = true;
} else {
$opcode_stats = array('stat_flag' => 'xcache.stat', 'memory_used' => 0, 'memory_avail' => 0, 'memory_total' => 0, 'hit_hit' => 0, 'hit_miss' => 0, 'hit_total' => 0, 'type' => 'xcache');
foreach (range(0, xcache_count(XC_TYPE_PHP) - 1) as $index) {
$info = xcache_info(XC_TYPE_PHP, $index);
$opcode_stats['hit_hit'] += $info['hits'];
$opcode_stats['hit_miss'] += $info['misses'];
$opcode_stats['hit_total'] += $info['hits'] + $info['misses'];
$opcode_stats['memory_used'] += $info['size'] - $info['avail'];
$opcode_stats['memory_avail'] += $info['avail'];
$opcode_stats['memory_total'] += $info['size'];
}
$opcode_stats['memory_used'] /= $opcode_stats['memory_total'];
$opcode_stats['memory_avail'] /= $opcode_stats['memory_total'];
$opcode_stats['hit_hit'] /= $opcode_stats['hit_total'];
$opcode_stats['hit_miss'] /= $opcode_stats['hit_total'];
}
$opcode_stats['opcode_cache'] = 'XCache';
} elseif (function_exists('wincache_ocache_fileinfo') && ini_get('wincache.ocenabled') == '1') {
$opcode_stats = array('opcode_cache' => 'WinCache', 'stat_flag' => 'wincache.ocenabled', 'memory_used' => 0, 'memory_avail' => 0, 'memory_total' => 0, 'hit_hit' => 0, 'hit_miss' => 0, 'hit_total' => 0, 'type' => 'wincache');
$info = wincache_ocache_fileinfo();
$opcode_stats['hit_hit'] = $info['total_hit_count'];
$opcode_stats['hit_miss'] = $info['total_miss_count'];
$opcode_stats['hit_total'] = $info['total_hit_count'] + $info['total_miss_count'];
$memory = wincache_ocache_meminfo();
$opcode_stats['memory_avail'] = $memory['memory_free'];
$opcode_stats['memory_total'] = $memory['memory_total'];
$opcode_stats['memory_used'] = $memory['memory_total'] - $memory['memory_free'];
$opcode_stats['memory_used'] /= $opcode_stats['memory_total'];
$opcode_stats['memory_avail'] /= $opcode_stats['memory_total'];
$opcode_stats['hit_hit'] /= $opcode_stats['hit_total'];
$opcode_stats['hit_miss'] /= $opcode_stats['hit_total'];
} elseif (function_exists('opcache_get_status') && ini_get('opcache.enable') == '1') {
$opcode_stats['opcode_cache'] = 'OpCache';
$status = opcache_get_status();
$opcode_stats['hit_hit'] = $status['opcache_statistics']['hits'];
$opcode_stats['hit_miss'] = $status['opcache_statistics']['misses'];
$opcode_stats['hit_total'] = $status['opcache_statistics']['hits'] + $status['opcache_statistics']['misses'];
$opcode_stats['memory_avail'] = $status['memory_usage']['free_memory'];
$opcode_stats['memory_used'] = $status['memory_usage']['used_memory'];
$opcode_stats['memory_total'] = $status['memory_usage']['used_memory'] + $status['memory_usage']['free_memory'];
$opcode_stats['memory_used'] /= $opcode_stats['memory_total'];
$opcode_stats['memory_avail'] /= $opcode_stats['memory_total'];
$opcode_stats['hit_hit'] /= $opcode_stats['hit_total'];
$opcode_stats['hit_miss'] /= $opcode_stats['hit_total'];
}
// Make results easier to read
$opcode_stats['memory_used'] = round($opcode_stats['memory_used'], 2);
$opcode_stats['memory_avail'] = round($opcode_stats['memory_avail'], 2);
$opcode_stats['hit_hit'] = round($opcode_stats['hit_hit'], 2);
$opcode_stats['hit_miss'] = round($opcode_stats['hit_miss'], 2);
if (isset($opcode_stats['hit_total'])) {
$opcode_stats = array_merge($opcode_stats, array('warning_fresh' => $opcode_stats['hit_total'] < 10000, 'warning_ratio' => $opcode_stats['hit_hit'] < 0.8));
}
if (isset($opcode_stats['memory_total'])) {
$opcode_stats = array_merge($opcode_stats, array('warning_starve' => $opcode_stats['memory_avail'] < 0.2, 'warning_low' => $opcode_stats['memory_total'] < 60 * 1024 * 1024));
}
$stat_flag = $opcode_stats['stat_flag'];
if ($stat_flag) {
$opcode_stats['warning_check'] = (bool) ini_get($stat_flag);
}
return $opcode_stats;
}
示例10: array
$columns = array("name", "hits", "ctime", "file_mtime", "refcount", "phprefcount", "file_size");
}
/* grab the cache array */
$entries = $nvBoot->get_cache_array($r);
/* has the user cache been requested */
if ($r == "user") {
/* cycle through the user caches */
for ($x = 0; $x < xcache_count(XC_TYPE_VAR); $x++) {
/* grab information on the user cache */
$info[$x] = xcache_info(XC_TYPE_VAR, $x);
}
} else {
/* cycle through the opcode caches */
for ($x = 0; $x < xcache_count(XC_TYPE_PHP); $x++) {
/* grab information on the opcode cache */
$info[$x] = xcache_info(XC_TYPE_PHP, $x);
}
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>NVOY - <?php
echo $nvBoot->fetch_entry("current");
?>
</title>
<meta name="Generator" content="NVOYX Open Source CMS">
<link rel="icon" type="image/png" href="/favicon.png">
<link href='//fonts.googleapis.com/css?family=Lato:300normal,400normal&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<style>
示例11: processClear
processClear();
// }}}
// {{{ load info/list
$cacheinfos = array();
for ($i = 0; $i < $pcnt; $i++) {
$data = xcache_info(XC_TYPE_PHP, $i);
if ($type === XC_TYPE_PHP) {
$data += xcache_list(XC_TYPE_PHP, $i);
}
$data['type'] = XC_TYPE_PHP;
$data['cache_name'] = "php#{$i}";
$data['cacheid'] = $i;
$cacheinfos[] = $data;
}
for ($i = 0; $i < $vcnt; $i++) {
$data = xcache_info(XC_TYPE_VAR, $i);
if ($type === XC_TYPE_VAR) {
$data += xcache_list(XC_TYPE_VAR, $i);
}
$data['type'] = XC_TYPE_VAR;
$data['cache_name'] = "var#{$i}";
$data['cacheid'] = $i;
$cacheinfos[] = $data;
}
// }}}
// {{{ merge the list
switch ($type) {
case XC_TYPE_PHP:
case XC_TYPE_VAR:
$cachelist = array('type' => $type, 'cache_list' => array(), 'deleted_list' => array());
if ($type == XC_TYPE_VAR) {
示例12: getStats
/**
* Echoes the stats of the cache.
*
* Gives the cache hits, cache misses and cache uptime.
*
* @since 6.2.0
*/
public function getStats()
{
if (!$this->enable) {
return false;
}
$info = xcache_info(XC_TYPE_VAR, 0);
echo "<p>";
echo "<strong>" . _t('Cache Hits:') . "</strong> " . $info['hits'] . "<br />";
echo "<strong>" . _t('Cache Misses:') . "</strong> " . $info['misses'] . "<br />";
echo "<strong>" . _t('Uptime:') . "</strong> " . null . "<br />";
echo "<strong>" . _t('Memory Usage:') . "</strong> " . $info['size'] . "<br />";
echo "<strong>" . _t('Memory Available:') . "</strong> " . $sma['avail'] . "<br />";
echo "</p>";
}
示例13: getInfo
/**
* @return array
*/
public function getInfo()
{
if ($this->isActive()) {
return xcache_info(XC_TYPE_VAR, 0);
}
}
示例14: stats
/**
* Returns an array with stats and usage informations for display.
*
* @return array
*/
public function stats()
{
$this->checkAuthorizationIsOff();
$info = xcache_info(XC_TYPE_VAR, 0);
return [CacheInterface::STATS_HITS => $info['hits'], CacheInterface::STATS_MISSES => $info['misses'], CacheInterface::STATS_UPTIME => null, CacheInterface::STATS_MEMORY_USAGE => $info['size'], CacheInterface::STATS_MEMORY_AVAILABLE => $info['avail']];
}
示例15: onPageComplete
function onPageComplete($page = false)
{
global $debug_total_time;
global $debug_total_sql_query;
global $debug_sql_query_stack;
$debug_total_string = '';
if (isset($debug_total_time) && $debug_total_time) {
$time = microtime(true) - $debug_total_time;
$debug_total_memory = function_exists('memory_get_peak_usage') ? memory_get_peak_usage() : 0;
$debug_total_string .= sprintf('<div style="z-index:9999;position:fixed;right:50px;top:5px;height:23px;padding:0px;padding-bottom:2px;font-weight:bolder;color:green;background-color:#000033;opacity:0.8;border:1px dotted grey;"><span style="padding-left:10px;color:%s;">%0.3f s</span>' . "\t", $time > 0.5 ? $time > 1 ? 'red' : 'yellow' : 'green', $time);
if ($debug_total_memory) {
$debug_total_memory /= 1048576;
$debug_total_string .= sprintf('<span style="padding-left:10px;color:%s;"> %0.3f MB</span>' . "\t", $debug_total_memory > 8 ? $debug_total_memory > 16 ? 'red' : 'yellow' : 'green', $debug_total_memory);
}
if (extension_loaded('eAccelerator')) {
$eaccelerator_info = eaccelerator_info();
if ($eaccelerator_info['cache']) {
$debug_total_string .= sprintf('<span style="padding-left:10px;color:%s;"> eAccelerator %s [%0.2fMB(%d%%)/%d scripts]</span>' . "\t" . "\n", 'cyan', $eaccelerator_info['version'], $eaccelerator_info['memoryAllocated'] / 1048576, 100 * $eaccelerator_info['memoryAllocated'] / $eaccelerator_info['memorySize'], $eaccelerator_info['cachedScripts']);
}
} elseif (extension_loaded('xCache')) {
if (isset($_GET['xcache'])) {
$pcnt = xcache_count(XC_TYPE_PHP);
$total = array('size' => 0, 'avail' => 0, 'cached' => 0, 'slots' => 0);
$fields = array('size', 'avail', 'cached', 'slots');
for ($i = 0; $i < $pcnt; $i++) {
$data = xcache_info(XC_TYPE_PHP, $i);
foreach ($fields as $field) {
$total[$field] += $data[$field];
}
}
$total['used'] = $total['size'] - $total['avail'];
$version = phpversion('xcache');
$debug_total_string .= sprintf('<span style="padding-left:10px;color:%s;"> xCache %s [%0.2fMB(%d%%)/%d scripts]</span>' . "\t" . "\n", 'cyan', $version, $total['used'] / 1048576, 100 * $total['used'] / $total['size'], $total['cached']);
} else {
$version = phpversion('xcache');
$debug_total_string .= sprintf('<span style="padding-left:10px;color:%s;"> xCache %s</span>' . "\t" . "\n", 'cyan', $version);
}
}
$debug_total_string .= sprintf('<span style="padding-left:10px;color:%s;"> %d SQL query</span>' . "\t" . "\n", $debug_total_sql_query > 50 ? $debug_total_sql_query > 100 ? 'red' : 'yellow' : 'green', $debug_total_sql_query);
$debug_total_string .= sprintf('<span style="padding-left:10px;"> %d File(s)</span>' . "\t" . "\n", count(get_included_files()));
$page_size = ob_get_length();
$debug_total_string .= sprintf('<span style="padding-left:10px;"> %0.3f KB page size</span>' . "\t", ($page_size ? $page_size : strlen($page)) / 1024);
//$debug_total_string .= sprintf('<span style="padding-left:10px;"> %s mode</span>',false?'DEV':'PRODUCTION');
$debug_total_string .= '<img style="padding:0;padding-left:10px;margin:0;cursor:pointer;" src="' . URL_IMAGES_COMMON . '/close.gif" title="close" alt="close" onclick="this.parentNode.style.display=\'none\';"></div>';
$firebug_enabled = false;
if (class_exists('FirePHP')) {
$firebug_enabled = strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'firephp') === false ? false : true;
$firebug = FirePHP::getInstance(true);
$firebug_enabled = $firebug->detectClientExtension();
$firebug->setEnabled($firebug_enabled);
$firebug->info(strip_tags($debug_total_string), basename(__FILE__));
if ($debug_sql_query_stack && (isset($_COOKIE['debug']) && $_COOKIE['debug'] == 'sql')) {
$total = 0.0;
foreach ($debug_sql_query_stack as $stack_item) {
$total += $stack_item['time'];
}
$debug_sql_query_stack[] = array('#' => 'TOTAL', 'time' => sprintf('%0.2f', $total), 'query' => '');
$firebug->table('SQL', $debug_sql_query_stack);
}
}
if (!SystemSettings::is_hosted() && (isset($_COOKIE['debug']) && $_COOKIE['debug'] == 'log') && ($fp = @fopen(DIR_TEMP . '/access.' . date("Y.m.d") . '.log', "a"))) {
@fwrite($fp, date("Y-m-d H:i:s") . "\t" . $_REQUEST['REQUEST_URI'] . $_REQUEST['QUERY_STRING'] . "\t" . preg_replace('/\\s+/', ' ', strip_tags($debug_total_string)) . "\n");
if ($debug_sql_query_stack) {
foreach ($debug_sql_query_stack as $query) {
@fwrite($fp, "\t" . implode("\t", $query) . "\n\n");
}
@fwrite($fp, "\n\n==========================================\n");
}
@fclose($fp);
}
}
session_write_close();
if ($page) {
if (!$firebug_enabled) {
print preg_replace('@</body>\\s*</html>\\s*$@', '', $page);
print $debug_total_string . '
</body>
</html>';
} else {
print $page;
return $debug_total_string;
}
}
}