1

I got problem with Opcache. It's not working as I wish/desire..

This is my opcache configuration

cat /etc/php/7.1/apache2/php.ini | grep opcache
[opcache]
opcache.enable = 1
opcache.enable_cli = 1
opcache.memory_consumption = 256
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 8882
;opcache.max_wasted_percentage=5
;opcache.use_cwd=1
opcache.validate_timestamps = 0
opcache.revalidate_freq = 0
;opcache.revalidate_path=0
;opcache.save_comments=1
opcache.fast_shutdown = 1
;opcache.enable_file_override=0
;opcache.optimization_level=0xffffffff
;opcache.inherited_hack=1
;opcache.dups_fix=0
;opcache.blacklist_filename=
;opcache.max_file_size=0
;opcache.consistency_checks=0
;opcache.force_restart_timeout=180
;opcache.error_log=
;opcache.log_verbosity_level=1
;opcache.preferred_memory_model=
;opcache.protect_memory=0
;opcache.restrict_api=
;opcache.mmap_base=
;opcache.file_cache=
;opcache.file_cache_only=0
;opcache.file_cache_consistency_checks=1
; Implies opcache.file_cache_only=1 for a certain process that failed to
;opcache.file_cache_fallback=1
;opcache.huge_code_pages=1
;opcache.validate_permission=0
;opcache.validate_root=0

Since my setting opcache.validate_timestamps = 0 is set to false, as far as i know, modifying any php file shouldn't take any affect until i release it with php function opcache_reset();

So I made a little test and I have changed my index.php file (via terminal). I have inserted a method print_r(opcache_get_status());

This is the result:

array (
    [opcache_enabled] => 1
    [cache_full] => 
    [restart_pending] => 1
    [restart_in_progress] => 
    [memory_usage] => Array
        (
            [used_memory] => 37994008
            [free_memory] => 230441448
            [wasted_memory] => 0
            [current_wasted_percentage] => 0
        )

    [interned_strings_usage] => Array
        (
            [buffer_size] => 16777216
            [used_memory] => 504816
            [free_memory] => 16272400
            [number_of_strings] => 11672
        )

    [opcache_statistics] => Array
        (
            [num_cached_scripts] => 64
            [num_cached_keys] => 111
            [max_cached_keys] => 16229
            [hits] => 0
            [start_time] => 1513234045
            [last_restart_time] => 1513263246
            [oom_restarts] => 0
            [hash_restarts] => 0
            [manual_restarts] => 124
            [misses] => 358
            [blacklist_misses] => 0
            [blacklist_miss_ratio] => 0
            [opcache_hit_rate] => 0
        )

)

My problem is that results of print_r(opcache_get_status()); should not be visible, since my opcache.validate_timestamps is set to false and changes should take affect only when I reload opcache files, via opcache_reset(); method.

Am I right or am I missing something? If you need any additional informations, please let me know and I will provide. Thank you!

UPDATE

I found out that not all files are caching... Running following command find . -type f -print | grep php | wc -l reports that there are 6167 php files, so why there are only 64 num_cached_scripts

Valor_
  • 125
  • 1
  • 8

1 Answers1

1

I found out what the problem was. After going trough code i found out, that some one implemented opcache_reset(); after each request. After removing that line of code, cache is working.

Valor_
  • 125
  • 1
  • 8