37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
// Check if OPCache is enabled
|
|
if (!function_exists('opcache_reset')) {
|
|
echo json_encode(['status' => 'error', 'message' => 'OPCache is not installed']);
|
|
exit(1);
|
|
}
|
|
|
|
// Reset OPCache
|
|
$result = opcache_reset();
|
|
if ($result === false) {
|
|
echo json_encode(['status' => 'error', 'message' => 'Failed to reset OPCache']);
|
|
exit(1);
|
|
}
|
|
|
|
// Get status after reset
|
|
$status = opcache_get_status(false);
|
|
if ($status === false) {
|
|
echo json_encode(['status' => 'error', 'message' => 'Failed to get OPCache status after reset']);
|
|
exit(1);
|
|
}
|
|
|
|
echo json_encode([
|
|
'status' => 'success',
|
|
'message' => 'OPCache cleared successfully',
|
|
'data' => [
|
|
'memory_usage' => [
|
|
'used' => $status['memory_usage']['used_memory'],
|
|
'free' => $status['memory_usage']['free_memory'],
|
|
'wasted' => $status['memory_usage']['wasted_memory']
|
|
],
|
|
'statistics' => [
|
|
'num_cached_scripts' => $status['opcache_statistics']['num_cached_scripts'],
|
|
'hits' => $status['opcache_statistics']['hits'],
|
|
'misses' => $status['opcache_statistics']['misses']
|
|
]
|
|
]
|
|
], JSON_PRETTY_PRINT);
|