forked from samdark/realpath_cache_tuner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
realpath_cache_tuner.php
57 lines (47 loc) · 1.5 KB
/
realpath_cache_tuner.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>realpath() cache size tuner</title>
</head>
<body>
<?php
function iniSizeToBytes($value)
{
$value = trim($value);
$last = strtolower($value[strlen($value) - 1]);
switch($last) {
case 'g':
$value *= 1024;
case 'm':
$value *= 1024;
case 'k':
$value *= 1024;
}
return $value;
}
$current = realpath_cache_size();
$max = iniSizeToBytes(ini_get('realpath_cache_size'));
$ttl = ini_get('realpath_cache_ttl');
$percentUsed = $current * 100 / $max;
?>
<h1>realpath() cache size tuner</h1>
<ol>
<li>Read <a href="https://jpauli.github.io/2014/06/30/realpath-cache.html">Julien Pauli article</a>.</li>
<li>Warm up cache (visit all your project pages).</li>
<li>Run this script.</li>
<li>Adjust values in php.ini.</li>
</ol>
<h2>Cache size</h2>
<p><?= $current ?> of <?= $max ?> bytes used. It's <?= (int) $percentUsed ?>% of available cache.</p>
<?php if ($percentUsed > 90): ?>
<p>Consider increasing <code>realpath_cache_size</code> in your php.ini.</p>
<?php elseif ($percentUsed < 50): ?>
<p>Consider decreasing <code>realpath_cache_size</code> in your php.ini.</p>
<?php else: ?>
<p>Everything seems to be OK.</p>
<?php endif ?>
<h2>Cache TTL</h2>
<p>TTL is <?= $ttl ?> seconds.</p>
</body>
</html>