
Opcache에 문제가 있습니다. 내가 원하는 대로 작동하지 않습니다./원하는 대로 작동하지 않습니다.
이것은 내 opcache 구성입니다
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
내 설정이 opcache.validate_timestamps = 0
false로 설정되어 있기 때문에 내가 아는 한 PHP 파일을 수정해도 PHP 기능으로 릴리스할 때까지는 아무런 영향을 미치지 않습니다.opcache_reset();
그래서 저는 약간의 테스트를 했고 (터미널을 통해) index.php 파일을 변경했습니다. print_r(opcache_get_status()); 메소드를 삽입했습니다.
결과는 다음과 같습니다.
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가 false로 설정되어 있고 메서드를 통해 opcache 파일을 다시 로드할 때만 변경 사항이 적용되기 때문에 결과가 print_r(opcache_get_status());
표시되어서는 안 된다는 것 입니다 .opcache.validate_timestamps
opcache_reset();
내 말이 맞나요, 아니면 뭔가 빠졌나요? 추가 정보가 필요한 경우 알려주시면 제공해 드리겠습니다. 감사합니다!
업데이트
모든 파일이 캐싱되는 것은 아니라는 것을 알았습니다... 다음 명령을 실행하면 find . -type f -print | grep php | wc -l
6167개의 PHP 파일이 있다고 보고되는데 왜 num_cached_scripts가 64개만 있습니까?
답변1
문제가 무엇인지 알아냈습니다. 코드를 살펴본 후 opcache_reset();
각 요청 후에 일부 코드가 구현된다는 것을 알았습니다 . 해당 코드 줄을 제거하면 캐시가 작동합니다.