# opcache_is_script_cached(...) for file cache

- Thread: https://externals.io/message/126077
- Original archive: https://news-web.php.net/php.internals/126077
- Started by Samuel Melrose on 2024-11-28T16:58:04+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #126077 — Samuel Melrose — 2024-11-28T16:58:04+00:00

URL: https://externals.io/message/126077#126077

Hello,

I'd like to propose a version of `opcache_is_script_cached(...)` that
supports checking the file cache, rather than just SHM.

This would be useful when paired with `opcache.file_cache_read_only`,
as it would allow us to more easily check the cache is being used at
runtime.

It'll also allow us to more easily write automated tests against the
file based opcache, which I'd like to do retroactively for my
`opcache.file_cache_read_only` PR.

An example PR for this change is here:

https://github.com/php/php-src/pull/16979

I'd initially considered changing the function definition to
`opcache_is_script_cached(string $filename, bool $file_cache =
false)`, adding a new parameter, `bool $file_cache = false`, but
defaulting to `false` so the default / existing behaviour remains the
same: when the second parameter is true, it'll check JUST the file
cache, not SHM.

@Ilija Tovilo has suggested that it might be less confusing to make it
its own function, which I'm happy to do.

Does anyone want to weigh in on what you think of this functionality,
and if/how you'd like to see it implemented?

Regards,
Samuel Melrose
