aptget php opcache,php opcache 系列函数翻译笔记

这个系列的函数之前完全没接触,一直只听到大神们常提opcache,就从了解这些最基础的函数开始吧。感觉翻译的还是有很大的出入,以后再慢慢完善吧。

opcache_compile_file

Compiles and caches a PHP script without executing it

无需执行即可编译、缓存PHP脚本

This function compiles a PHP script and adds it to the opcode cache without executing it.

This can be used to prime the cache after a Web server restart by pre-caching files that will be included in later requests.

在不运行某个PHP脚本的情况下,该函数可以编译该脚本并将其添加到字节码缓存中去。

该函数可以用于在Web服务器重启之后初始化缓存,以供后续请求调用。(该句中的by是怎么个情况,只能大致翻译为:该函数可以用于在Web服务器重启之后  对一些需要缓存的文件  进行初始化缓存,以供后续请求调用)

The path to the PHP script to be compiled.

被编译的 PHP 脚本的路径。

If file cannot be loaded or compiled, an error of level E_WARNING is generated. You may use @ to suppress this warning.

如果文件不能被载入或者不能被编译,则会生成一个E_WARNING级别的错误。可以使用@来抑制该警告。

opcache_get_configuration

Get configuration information about the cache

This function returns configuration information about the cache instance

Returns an array of information, including ini, blacklist and version

If opcache.restrict_api is in use and the current path is in violation of the rule, an E_WARNING will be raised; no status information will be returned.

获取缓存的配置信息。

该函数将返回缓存实例的配置信息。

返回一个数组,该数组里包含了缓存的初始化信息,黑名单和版本号。

在启用了opcache.restrict_api的情况下,如果当前路径在禁止规则里,将会出现 E_WARNING ;不会返回任何状态信息。

opcache_get_status

Get status information about the cache

This function returns state information about the cache instance

Returns an array of information, optionally containing script specific state information

If opcache.restrict_api is in use and the current path is in violation of the rule, an E_WARNING will be raised; no status information will be returned.

获取缓存的状态信息。

该函数将返回缓存实例的状态信息。

返回一个数组,该数组可能包含有脚本具体的声明信息。

在启用了opcache.restrict_api的情况下,如果当前路径在禁止规则里,将会出现 E_WARNING ;不会返回任何状态信息。

opcache_invalidate

booleanopcache_invalidate(string $script[,boolean $force= FALSE] )

Invalidates a cached script

This function invalidates a particular script from the opcode cache. If force is unset or FALSE, the script will only be invalidated if the modification time of the script is newer than the cached opcodes.

Parameters :script - The path to the script being invalidated.

Parameters :force - If set to TRUE, the script will be invalidated regardless of whether invalidation is necessary.

Returns TRUE if the opcode cache for script was invalidated or if there was nothing to invalidate, or FALSE if the opcode cache is disabled.

废除脚本缓存

该函数的作用是使得指定脚本的字节码缓存失效。如果force没有设置或者传入的是FALSE,那么只有当脚本的修改时间比对应字节码的时间更新,脚本的缓存才会失效。

参数:script - 缓存需要被作废对应的脚本路径

参数:force - 如果该参数设置为TRUE,那么不管是否必要,该脚本的缓存都将被废除。

如果脚本的字节码缓存失效设置成功或者该脚本本来就没有缓存,则返回TRUE;如果字节码缓存被禁用,则返回FALSE。

opcache_reset

Resets the contents of the opcode cache

This function resets the entire opcode cache. After calling opcache_reset(), all scripts will be reloaded and reparsed the next time they are hit.

Returns TRUE if the opcode cache was reset, or FALSE if the opcode cache is disabled.

重置字节码缓存的内容

该函数将重置整个字节码缓存。在调用 opcache_reset() 之后,所有的脚本将会重新载入并且在下次被点击的时候重新解析。

如果字节码缓存被重置成功,则返回 TRUE;如果字节码缓存被禁用,则返回 FALSE。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值