1、PHP开启opcache方法:
打开php.ini文件,找到[opcache],做如下设置:
zend_extension=\"大众D:/wamp/PHP56/ext/php_opcache.dll\公众
; dll地址,按照自己的路径定义

opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=4
opcache.max_accelerated_files=2000
opcache.max_wasted_percentage=5
opcache.use_cwd=0
opcache.validate_timestamps=1
opcache.revalidate_freq=2
opcache.save_comments=1
opcache.fast_shutdown=1
2、重启Apache:
3、利用phpinfo()查看是否成功开启:
4、利用
对付Opcache的利用,紧张表示在其供应的几个函数:
1、opcache_get_configuration;
形式:array opcache_get_configuration(void);
获取设置的缓存配置信息,以数组形式返回配置信息、黑名单及版本号。
2、opcache_get_status;
形式:array opcache_get_status(void);
获取设置的缓存状态信息。
3、opcache_invalidate;
形式:boolean opcache_invalidate (string);
该函数的浸染是使得指定脚本的字节码缓存失落效。如果force 没有设置或者传入的是 FALSE,那么只有当脚本的修正韶光 比对应字节码的韶光更新,脚本的缓存才会失落效。
4、opcache_reset;
形式:boolean opcache_reset(void);
该函数将重置全体字节码缓存。在调用 opcache_reset() 之后,所有的脚本将会重新载入并且不才次被点击的时候重新解析。
5、opcache_compile_file;
形式:boolean opcache_compile_file (string);
无需运行,就可以编译并缓存脚本。
6、opcache_is_script_cached
形式:boolean opcache_is_script_cached (string);
判断某个脚本是否已经缓存到Opcache。