If the opcache is disabled, this functions returns false.(PHP 5 >= 5.5.0, PHP 7, PHP 8, PECL ZendOpcache > 7.0.2)
opcache_get_status — キャッシュについてのステータス情報を取得
この関数は、インメモリ の キャッシュ・インスタンス についてのステータス情報を返します。 ファイルキャッシュに関する情報は一切返しません。
include_scriptsスクリプト固有の状態の情報を含む。
情報の配列を返します。スクリプト固有の状態の情報をオプションで含みます、
失敗した場合に false を返します。
opcache.restrict_api を使用中で、
かつ現在のパスがルール違反の場合、
E_WARNING が発生します。
ステータス情報は返されません。
| バージョン | 説明 |
|---|---|
| PHP 8.3.0 |
opcache_get_status()['scripts'][n]['revalidate'] の値に、
いつスクリプトの更新チェックを行うかの予定が Unix タイムスタンプの形で含まれるようになりました。
いつチェックを行うかは、INI ディレクティブ
opcache.revalidate_freq
によって決まります。
|
例1 opcache_get_status() の例
<?php
var_dump(opcache_get_status());
?>上の例の出力は、 たとえば以下のようになります。
array(9) {
'opcache_enabled' =>
bool(true)
'cache_full' =>
bool(false)
'restart_pending' =>
bool(false)
'restart_in_progress' =>
bool(false)
'memory_usage' =>
array(4) {
'used_memory' =>
int(9167936)
'free_memory' =>
int(125049792)
'wasted_memory' =>
int(0)
'current_wasted_percentage' =>
double(0)
}
'interned_strings_usage' =>
array(4) {
'buffer_size' =>
int(8388608)
'used_memory' =>
int(2593616)
'free_memory' =>
int(5794992)
'number_of_strings' =>
int(10358)
}
'opcache_statistics' =>
array(13) {
'num_cached_scripts' =>
int(0)
'num_cached_keys' =>
int(0)
'max_cached_keys' =>
int(16229)
'hits' =>
int(0)
'start_time' =>
int(1733310010)
'last_restart_time' =>
int(0)
'oom_restarts' =>
int(0)
'hash_restarts' =>
int(0)
'manual_restarts' =>
int(0)
'misses' =>
int(0)
'blacklist_misses' =>
int(0)
'blacklist_miss_ratio' =>
double(0)
'opcache_hit_rate' =>
double(0)
}
'scripts' =>
array(0) {
}
'jit' =>
array(7) {
'enabled' =>
bool(false)
'on' =>
bool(false)
'kind' =>
int(5)
'opt_level' =>
int(4)
'opt_flags' =>
int(6)
'buffer_size' =>
int(0)
'buffer_free' =>
int(0)
}
}
If the opcache is disabled, this functions returns false.