elcobvg/laravel-opcache
Composer 安装命令:
composer require elcobvg/laravel-opcache
包简介
Custom OPcache Cache Driver for Laravel. Faster than Redis or memcached.
README 文档
README
Custom OPcache Cache Driver for Laravel. Faster than Redis, Memcache or APC.
This package adds a cache driver to your Laravel project that uses PHP engine’s in-memory file caching (OPcache) to cache application data.
This method is faster than Redis, Memcache, APC, and other PHP caching solutions because all those solutions must serialize and unserialize objects. By storing PHP objects in file cache memory across requests, this driver can avoid serialization completely!
Installation
Require this package with composer.
composer require elcobvg/laravel-opcache
Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
If you don't use auto-discovery or Laravel version 5.4 or older, add the ServiceProvider to the providers array in config/app.php
ElcoBvg\Opcache\ServiceProvider::class,
Then, make sure you add the driver option to the stores array in config/cache.php
'opcache' => [ 'driver' => 'opcache', ],
And enable the driver in your .env file or in config/cache.php
OPcache configuration
OPcache can only be compiled as a shared extension. You must compile PHP with the --enable-opcache option for OPcache to be available.
OPcache must be enabled and configured in your php.ini. Look for the section starting with [OPcache] and enter the desired values. The more memory you can assign to OPcache, the faster your cache will be. The opcache.max_accelerated_files value should be high enough to hold all objects that need to be cached.
Since all PHP files will be cached with OPcache, it is not advisable to use it in a development environment, so only enable it in production. Alternatively, you can exclude PHP files from being cached by specifying a blacklist file with the opcache.blacklist_filename option.
opcache.enable=1 opcache.memory_consumption=512 opcache.interned_strings_buffer=64 opcache.max_accelerated_files=32500 opcache.validate_timestamps=1 opcache.save_comments=1 opcache.revalidate_freq=60 opcache.fast_shutdown=1 opcache.enable_cli=1
Graceful degradation: when OPcache is not enabled or installed, or memory is insufficient, this driver will still work but will read from the cached files instead of from memory. Since there's no unserialization required, it will still be faster than a regular file cache driver.
Caching Eloquent models
Depending on how you've configured caching in your project, you may want to cache full Eloquent models. If so, base your model classes on ElcoBvg\Opcache\Model instead of the regular Eloquent base model class, so they can be retrieved correctly from cache.
References
elcobvg/laravel-opcache 适用场景与选型建议
elcobvg/laravel-opcache 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 347.64k 次下载、GitHub Stars 达 43, 最近一次更新时间为 2017 年 11 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cache」 「driver」 「laravel」 「Opcache」 「webprofiler」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 elcobvg/laravel-opcache 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 elcobvg/laravel-opcache 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 elcobvg/laravel-opcache 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Galera cluster driver for Doctrine
A PHP client driver for the RethinkDB query language (ReQL)
Laravel 5 - Repositories to the database layer
Arikam CMS Driver package
Use a REST API as if it was your local database
统计信息
- 总下载量: 347.64k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 43
- 点击次数: 47
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-11-29