PHPackages                             flyokai/magento-amp-mate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. flyokai/magento-amp-mate

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

flyokai/magento-amp-mate
========================

Magento specific AMPHP helpers

0.1.0(1mo ago)00MITPHP

Since Apr 25Pushed 2w agoCompare

[ Source](https://github.com/flyokai/magento-amp-mate)[ Packagist](https://packagist.org/packages/flyokai/magento-amp-mate)[ RSS](/packages/flyokai-magento-amp-mate/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (5)Versions (6)Used By (0)

flyokai/magento-amp-mate
========================

[](#flyokaimagento-amp-mate)

> User docs → [`README.md`](README.md) · Agent quick-ref → [`CLAUDE.md`](CLAUDE.md) · Agent deep dive → [`AGENTS.md`](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`](../amp-mate/README.md).

Features
--------

[](#features)

- **`Rewrite\CmCacheBackendFile`** — async file cache backend, 100% protocol-compatible with the Magento cache front-ends
- **`MageCache\Data\AmpStreamReader`** — async stream parser for the metadata + data layout used by Magento cache files
- Optional `flock` via `ampFlock()` for safe concurrent access

Installation
------------

[](#installation)

```
composer require flyokai/magento-amp-mate
```

CmCacheBackendFile
------------------

[](#cmcachebackendfile)

`Rewrite\CmCacheBackendFile` extends Magento's `Cm_Cache_Backend_File` and replaces blocking file I/O with AMPHP equivalents:

- `_getCache()` — async read via `AmpStreamReader`
- `save()` — async write with optional `flock`
- `_clean()` — async recursive cleanup
- `_filePutContents()` — uses `Amp\File\openFile()` with optional locking
- `_fileGetContents()` — buffered read via `ampStreamBuffer()`

Wire it into Magento's cache configuration as you would any other cache backend implementation.

AmpStreamReader
---------------

[](#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
-------

[](#gotchas)

- **Mixed sync/async in `_clean()`** — uses `is_dir()` / `rmdir()` (sync) alongside async operations.
- **`AmpStreamReader` consumes parser state** — calling `getMeta()` before `getData()` 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
--------

[](#see-also)

- [`flyokai/amp-mate`](../amp-mate/README.md) — `ampFlock`, `ampOpenFile`, and friends
- [`flyokai/magento-dto`](../magento-dto/README.md) — Magento DTOs

License
-------

[](#license)

MIT

###  Health Score

33

—

LowBetter than 73% of packages

Maintenance94

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

44d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/247743048?v=4)[flyokai](/maintainers/flyokai)[@flyokai](https://github.com/flyokai)

---

Top Contributors

[![flyokai](https://avatars.githubusercontent.com/u/247743048?v=4)](https://github.com/flyokai "flyokai (5 commits)")

### Embed Badge

![Health badge](/badges/flyokai-magento-amp-mate/health.svg)

```
[![Health](https://phpackages.com/badges/flyokai-magento-amp-mate/health.svg)](https://phpackages.com/packages/flyokai-magento-amp-mate)
```

###  Alternatives

[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k885.1k21](/packages/danog-madelineproto)[amphp/parallel

Parallel processing component for Amp.

85049.9M89](/packages/amphp-parallel)[amphp/process

A fiber-aware process manager based on Amp and Revolt.

25657.8M64](/packages/amphp-process)[amphp/redis

Efficient asynchronous communication with Redis servers, enabling scalable and responsive data storage and retrieval.

164685.0k55](/packages/amphp-redis)[kelunik/acme

ACME library written in PHP.

121609.1k3](/packages/kelunik-acme)[phel-lang/phel-lang

Phel is a functional programming language that compiles to PHP

5085.1k16](/packages/phel-lang-phel-lang)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
