Changeset 2196791
- Timestamp:
- 11/19/2019 08:35:39 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
clear-opcache/trunk/clear_op_cache_plugin.php
r2193039 r2196791 122 122 add_action('admin_post_cocp_clear_opcache', 'bc_cocp_clearopcache'); 123 123 124 function bc_cocp_register_options_page() { 125 add_options_page('OPcache Details', 'OPcache', 'manage_options', 'bc_cocp', 'bc_cocp_options_page'); 126 } 127 add_action('admin_menu', 'bc_cocp_register_options_page'); 128 129 function bc_cocp_options_page() { 130 $status = opcache_get_status(); 131 132 if (!$status) { 133 ?> 134 <b>OPcache is disabled. You should enabled it.</b><br><br> 135 <a href="https://www.php.net/manual/en/book.opcache.php">https://www.php.net/manual/en/book.opcache.php</a> 136 <?php 137 return; 138 } 139 140 $enabled = $status['opcache_enabled'] ? "Yes" : "No"; 141 $cache_full = $status['cache_full'] ? "Yes" : "No"; 142 143 $restart_pending = $status["restart_pending"] ? "Yes" : "No"; 144 $restart_in_progress = $status["restart_in_progress"] ? "Yes" : "No"; 145 146 $used_memory = floor($status["memory_usage"]["used_memory"] / 1000000); 147 $free_memory = floor($status["memory_usage"]["free_memory"] / 1000000); 148 149 $cached_scripts_count = $status["opcache_statistics"]["num_cached_scripts"]; 150 $cached_keys_count = $status["opcache_statistics"]["num_cached_keys"]; 151 152 $hits = $status["opcache_statistics"]["hits"]; 153 154 $config = opcache_get_configuration(); 155 156 $version = $config["version"]["version"] . " " . $config["version"]["opcache_product_name"]; 157 158 $directives = $config["directives"]; 159 160 ?> 161 <br> 162 <button id="cocp-clear-btn">Flush OPcache</button><br> 163 164 <script> 165 var cocp_clear_btn = document.getElementById('cocp-clear-btn'); 166 cocp_clear_btn.onclick = function() { 167 bc_cocp_clearopcache(); 168 } 169 </script> 170 171 <b>Memory Used/Available</b>: <i><?php echo $used_memory . "MB / " . $free_memory . "MB"; ?></i><br><br> 172 173 <h2>Stats</h2> 174 175 <b>Enabled</b>: <i><?php echo $enabled; ?></i><br> 176 <b>Cache Full</b>: <i><?php echo $cache_full; ?></i><br> 177 178 <br> 179 180 <b>Restart Pending</b>: <i><?php echo $restart_pending; ?></i><br> 181 <b>Restart In-Progress</b>: <i><?php echo $restart_in_progress; ?></i><br> 182 183 <br> 184 185 <b>Number of Cached Scripts</b>: <i><?php echo $cached_scripts_count; ?></i><br> 186 <b>Number of Cached Keys </b>: <i><?php echo $cached_keys_count; ?></i><br> 187 188 <br> 189 190 <b>Total Hits</b>: <i><?php echo $hits; ?></i><br> 191 192 <h2>Configuration</h2> 193 194 <b>Version</b>: <i><?php echo $version; ?></i><br> 195 196 <br> 197 198 <b>Directives (<a href="https://www.php.net/manual/en/opcache.configuration.php">documentation</a>)</b><br> 199 200 <?php foreach($directives as $key=>$d): ?> 201 <b><?php echo $key; ?></b>: <i><?php echo $d; ?></i><br> 202 <?php endforeach; ?> 203 <?php 204 } 124 205 ?>
Note: See TracChangeset
for help on using the changeset viewer.