Skip to content

Commit 62765b7

Browse files
committed
opcache: file_cache_read_only code review update 7 (#16484)
1 parent 112b9d6 commit 62765b7

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,9 +1412,7 @@ zend_result zend_accel_invalidate(zend_string *filename, bool force)
14121412
}
14131413

14141414
if (ZCG(accel_directives).file_cache) {
1415-
if (!ZCG(accel_directives).file_cache_read_only) {
1416-
zend_file_cache_invalidate(realpath);
1417-
}
1415+
zend_file_cache_invalidate(realpath);
14181416
}
14191417

14201418
persistent_script = zend_accel_hash_find(&ZCSG(hash), realpath);

ext/opcache/zend_file_cache.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,10 @@ zend_persistent_script *zend_file_cache_script_load(zend_file_handle *file_handl
20132013

20142014
void zend_file_cache_invalidate(zend_string *full_path)
20152015
{
2016+
if (ZCG(accel_directives).file_cache_read_only) {
2017+
return;
2018+
}
2019+
20162020
char *filename;
20172021

20182022
filename = zend_file_cache_get_bin_file_path(full_path);

php.ini-development

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,15 @@ ldap.max_links = -1
17661766
; SHM reset. The default "" disables file based caching.
17671767
;opcache.file_cache=
17681768

1769+
; Enables or disables read-only mode for the second level cache directory.
1770+
; It should improve performance for read-only containers,
1771+
; when the cache is pre-warmed and packaged alongside the application.
1772+
; Best used with `opcache.validate_timestamps=0`, `opcache.enable_file_override=1`
1773+
; and `opcache.file_cache_consistency_checks=0`.
1774+
; Note: A cache generated with a different build of PHP, a different file path,
1775+
; or different settings (including which extensions are loaded), may be ignored.
1776+
;opcache.file_cache_read_only=0
1777+
17691778
; Enables or disables opcode caching in shared memory.
17701779
;opcache.file_cache_only=0
17711780

php.ini-production

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,15 @@ ldap.max_links = -1
17681768
; SHM reset. The default "" disables file based caching.
17691769
;opcache.file_cache=
17701770

1771+
; Enables or disables read-only mode for the second level cache directory.
1772+
; It should improve performance for read-only containers,
1773+
; when the cache is pre-warmed and packaged alongside the application.
1774+
; Best used with `opcache.validate_timestamps=0`, `opcache.enable_file_override=1`
1775+
; and `opcache.file_cache_consistency_checks=0`.
1776+
; Note: A cache generated with a different build of PHP, a different file path,
1777+
; or different settings (including which extensions are loaded), may be ignored.
1778+
;opcache.file_cache_read_only=0
1779+
17711780
; Enables or disables opcode caching in shared memory.
17721781
;opcache.file_cache_only=0
17731782

0 commit comments

Comments
 (0)