flyokai/magento-amp-mate
Composer 安装命令:
composer require flyokai/magento-amp-mate
包简介
Magento specific AMPHP helpers
README 文档
README
User docs →
README.md· Agent quick-ref →CLAUDE.md· Agent deep dive →AGENTS.md
Async Magento cache backend powered by AMPHP — file-based caching that doesn't block the event loop.
A drop-in replacement for Cm_Cache_Backend_File that performs file I/O via amphp/file, protecting reads/writes with ampFlock() from flyokai/amp-mate.
Features
Rewrite\CmCacheBackendFile— async file cache backend, 100% protocol-compatible with the Magento cache front-endsMageCache\Data\AmpStreamReader— async stream parser for the metadata + data layout used by Magento cache files- Optional
flockviaampFlock()for safe concurrent access
Installation
composer require flyokai/magento-amp-mate
CmCacheBackendFile
Rewrite\CmCacheBackendFile extends Magento's Cm_Cache_Backend_File and replaces blocking file I/O with AMPHP equivalents:
_getCache()— async read viaAmpStreamReadersave()— async write with optionalflock_clean()— async recursive cleanup_filePutContents()— usesAmp\File\openFile()with optional locking_fileGetContents()— buffered read viaampStreamBuffer()
Wire it into Magento's cache configuration as you would any other cache backend implementation.
AmpStreamReader
use Flyokai\MagentoAmpMate\MageCache\Data\AmpStreamReader; $reader = new AmpStreamReader(); $reader->parseStream($stream); $meta = $reader->getMeta(); // first line: serialised metadata $data = $reader->getData(); // remainder: cache payload
Layout: first line is serialised metadata, the rest is the cache data. The reader uses AMPHP's Parser class to keep state, so parsing is incremental.
Gotchas
- Mixed sync/async in
_clean()— usesis_dir()/rmdir()(sync) alongside async operations. AmpStreamReaderconsumes parser state — callinggetMeta()beforegetData()advances the cursor; ordering matters.- Random tag-file compaction — there's a 1% chance of rewriting tag files during merge.
_getTagIds()accepts multiple types — string path, AmpFile, or resource. Caller must be unambiguous.- File locking is optional — controlled by
$this->_options['file_locking']. Race conditions if disabled.
See also
flyokai/amp-mate—ampFlock,ampOpenFile, and friendsflyokai/magento-dto— Magento DTOs
License
MIT
flyokai/magento-amp-mate 适用场景与选型建议
flyokai/magento-amp-mate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 flyokai/magento-amp-mate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 flyokai/magento-amp-mate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-24