php 缓存使用监控测试代码。
将以下代码存在PHP WEB网站下面,然后通过IE浏览器进行访问。
#cat ocpcache.php
$config = opcache_get_configuration();
$status = opcache_get_status();
function size_for_humans($bytes) {
if ($bytes > 1048576) {
return sprintf("%.2f MB", $bytes/1048576);
} else if ($bytes > 1024) {
return sprintf("%.2f kB", $bytes/1024);
} else return sprintf("%d bytes", $bytes);
}
?>
body{
font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;
margin:auto;
position:relative;
width:1024px;
}
text{
font:10px sans-serif;
}
form{
position: absolute;
right:210px;
top:50px;
}
#graph{
position: absolute;
right:0px;
top:80px;
}
#stats{
position: absolute;
right:234px;
top:240px;
}
tbody tr:nth-child(even) {
background-color:#eee;
}
p.capitalize{
text-transform:capitalize;
}
.tabs{
position:relative;
min-height:200px;
clear:both;
margin:25px 0;
}
.tab{
float:left;
}
.tab label{
background: #eee;
padding:10px;
border:1px solid #ccc;
margin-left:-1px;
position:relative;
left:1px;
}
.tab [type=radio]{
display: none;
}
.content{
position:absolute;
top:28px;
left: 0;
background:white;
padding:20px;
border:1px solid #ccc;
height:500px;
width:480px;
overflow-y:auto;
overflow-x:hidden;
}
.content table {
width:100%;
}
.clickable {
cursor: hand;
cursor: pointer;
}
[type=radio]:checked ~ label{
background: white;
border-bottom:1px solid white;
z-index:2;
}
[type=radio]:checked ~ label ~ .content{
z-index: 1;
}
PHP = phpversion()?> OpCache = $config['version']['version']?>
| $k | $v |
|---|---|
| $key | $value |
| $key | $value |
|---|
| Hits | Memory | Path | |
|---|---|---|---|
| {$dir} ({$count} files) | ";|||
| {$data["hits"]} | ";" .size_for_humans($data["memory_consumption"]). " | ";{$file} | ";{$dir}/{$file} | ";
$mem = $status['memory_usage'];
$stats = $status['opcache_statistics'];
$free_keys = $stats['max_cached_keys'] - $stats['num_cached_keys'];
echo <<



