Skip to content

Examples of using PHP 8.5's opcache.file_cache_read_only with Docker

Notifications You must be signed in to change notification settings

affordablemobiles/php85-file-cache-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

opcache.file_cache_read_only examples

Examples of pre-warming the opcache on PHP 8.5, for:

  • Linux based containers, i.e. Docker
  • Application code is read-only after container build

These examples are primarily for Google Cloud's App Engine, which builds Docker containers using buildpacks, which include all application code that remains read-only at runtime.

Examples

Notes

The opcache file based cache is only valid for the same build of PHP (not just a specific version match), so it's important that the opcache is generated at deploy / container build time with the exact same build of PHP.

This is due to zend_system_id being included in both the file path:

https://github.com/php/php-src/blob/85f7e5477a5cd81c221c3cc451bc76bdf3c8ac83/ext/opcache/zend_file_cache.c#L981-L1006

And also, in the cache files themselves:

https://github.com/php/php-src/blob/85f7e5477a5cd81c221c3cc451bc76bdf3c8ac83/ext/opcache/zend_file_cache.c#L954-961

You can debug this by setting opcache.log_verbosity_level=4.

On startup, if the file cache is enabled, you'll see a message with the PHP build ID:

https://github.com/php/php-src/blob/85f7e5477a5cd81c221c3cc451bc76bdf3c8ac83/ext/opcache/ZendAccelerator.c#L3332-L3335

About

Examples of using PHP 8.5's opcache.file_cache_read_only with Docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages