Among the data points returned by opcache_get_status() is:

'opcache_statistics' => [
    'num_cached_scripts' => 90,
    'num_cached_keys' => 96,
    'max_cached_keys' => 3907,
    ...
]

The number of cached scripts is correct and understandable (and can be confirmed by counting the 'scripts' part of the return value). But what exactly does "keys" refer to? I assume the Zend OPcache could be organized as a key/value store. In that case, there should be a one-to-one relationship between scripts and keys, unless...

  • the OPcache also stores something other than scripts, or
  • some of the scripts are stored using 2 or more keys

I didn't see an API for listing the keys used by the OPcache.

有帮助吗?

解决方案

OPcache keeps separate num_entries and num_direct_entries statistics for each of its hash tables; these values directly correspond to num_cached_keys and num_cached_scripts in the result of opcache_get_status.

There's comments in the code that directly supports your second assumption: some stuff is cached under more than one key.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top