简体   繁体   English

PHP 5.5中的Opcache不缓存任何内容

[英]Opcache in php 5.5 not caching anything

I have a LAMP system on Ubuntu 14.04 我在Ubuntu 14.04上有一个LAMP系统

I have made changes in the php.ini at the path /etc/php5/apache2/php.ini I have made the following changes in php.ini 我在/etc/php5/apache2/php.ini路径下的php.ini中进行了更改,在php.ini中进行了以下更改

opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=120

The reason I put opcache.enable_cli=1 is because i was getting the following error in php -i 我放入opcache.enable_cli = 1的原因是因为我在php -i中遇到以下错误

Opcode Caching => Disabled
Optimization => Disabled
Startup Failed => Opcode Caching is disabled for CLI

opcache.enable => On => On
opcache.enable_cli => Off => Off

After puting opcache.enable_cli=1, I get the following in php -i 放入opcache.enable_cli = 1后,我在php -i中得到以下内容

Zend OPcache

Opcode Caching => Up and Running
Optimization => Enabled
Startup => OK
Shared memory model => mmap
Cache hits => 0
Cache misses => 0
Used memory => 10707944
Free memory => 123509784
Wasted memory => 0
Cached scripts => 0
Cached keys => 0
Max keys => 3907
OOM restarts => 0
Hash keys restarts => 0
Manual restarts => 0

Directive => Local Value => Master Value
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => On => On
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.fast_shutdown => 1 => 1
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 8 => 8
opcache.load_comments => 1 => 1
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 2500 => 2500
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 128 => 128
opcache.optimization_level => 0xFFFFFFFF => 0xFFFFFFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 90 => 90
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_timestamps => On => On

Opcache is running but it is not caching anything. Opcache正在运行,但未缓存任何内容。 After a page loads for the first time and then I refresh the page within 90 seconds I see a different page 首次加载页面后,然后在90秒内刷新页面,我看到了另一个页面

You're misunderstanding what opcache is. 您误解了什么是opcache。 PHP files are just plain text. PHP文件只是纯文本。 They're not machine code. 它们不是机器代码。 So PHP has to parse that text and generate machine code (operation code, or opcode for short). 因此,PHP必须解析该文本并生成机器代码(操作代码或简称为操作码)。 Once it has that opcode, it can then run your program. 一旦有了该操作码,它就可以运行您的程序。

Opcache simply stores the opcodes. Opcache只是存储操作码。 It helps save overhead when the underlying code isn't changing a lot. 当基础代码变化不大时,它有助于节省开销。

What you're talking about is something like output caching , where the web server stores what it sends to the clients. 您正在谈论的是诸如输出缓存之类的东西,其中Web服务器存储了它发送给客户端的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM