webfixit/opcache

允许通过CLI和Magento2后端清除/清空/刷新PHP OpCache

安装数量: 23,870

依赖项: 0

建议者: 0

安全: 0

星标: 27

关注者: 5

分支: 6

公开问题: 1

类型:magento2-module

1.2.0 2018-05-10 20:01 UTC

This package is not auto-updated.

Last update: 2024-09-19 09:31:30 UTC


README

允许通过CLI和Magento2后端清除/清空/刷新PHP OpCache

未维护

我仍然在这个仓库(使用情况)中看到很多活动。我只是想说明,我不再维护这个插件了。这是因为我现在没有在用Magento工作。因此,我对添加新功能没有兴趣。尽管如此,你可以自由地提交pull请求,我会处理这些。

原因

因为PHP OpCache在当前的服务器/应用设置中几乎是事实上的标准。大多数用户/开发者都在使用简单的PHP脚本来清除缓存或简单地忽略这个缓存。通过这个扩展,你可以在构建/部署过程中通过CLI使用它。此外,还提供了一个扩展到Magento2后端。只需点击一下,你就可以清除缓存。

关于我

我在荷兰一家全服务数字代理公司担任DevOps工程师。尽可能的时候,我试图创建开源脚本/扩展和工具。如果你欣赏我的工作,请慷慨捐赠,这样我就可以继续喝啤酒了。

paypal

CLI的工作方式

通过CLI清除PHP OpCache是不可能的。我为此创建了一个解决方案。我们不是通过CLI运行静态PHP文件,而是进行curl请求。因为这是一个curl请求,你的web服务器实际上会通过"php cgi"解析这个请求。这样我们就可以清除它。

我们现在的问题是,我们不想让机器人或"黑客"能够清除这个缓存。因此,在执行过程中,我们写入一个类似"锁"的文件。显然,在清除后删除它。这样就不能直接访问这个静态页面。

扩展缓存管理

Magento2 Additional cache management

OpCache清除

Magento2 OpCache purge

CLI使用方法

php bin/magento opcache:status

返回opcache状态

bin/magento opcache:status
Array
(
    [opcache_enabled] => 1
    [cache_full] => 
    [restart_pending] => 
    [restart_in_progress] => 
    [memory_usage] => Array
        (
            [used_memory] => 78587744
            [free_memory] => 2068895904
            [wasted_memory] => 0
            [current_wasted_percentage] => 0
        )

    [interned_strings_usage] => Array
        (
            [buffer_size] => 20971520
            [used_memory] => 2283208
            [free_memory] => 18688312
            [number_of_strings] => 41723
        )

    [opcache_statistics] => Array
        (
            [num_cached_scripts] => 1289
            [num_cached_keys] => 1365
            [max_cached_keys] => 130987
            [hits] => 6
            [start_time] => 1510859030
            [last_restart_time] => 0
            [oom_restarts] => 0
            [hash_restarts] => 0
            [manual_restarts] => 0
            [misses] => 1289
            [blacklist_misses] => 0
            [blacklist_miss_ratio] => 0
            [opcache_hit_rate] => 0.46332046332046
        )

)
php bin/magento opcache:clear

将清除PHP OpCache

bin/magento opcache:clear
Cleared OpCache

使用Composer安装

composer require webfixit/opcache