PHPackages                             mimatus/export-cache - 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. [Caching](/categories/caching)
4. /
5. mimatus/export-cache

ActiveLibrary[Caching](/categories/caching)

mimatus/export-cache
====================

PSR-6 Cache without deserialization speeded-up with OPcache

00PHP

Since Aug 5Pushed 2y ago1 watchersCompare

[ Source](https://github.com/MiMatus/Export-Cache)[ Packagist](https://packagist.org/packages/mimatus/export-cache)[ RSS](/packages/mimatus-export-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

MiMatus\\ExportCache
====================

[](#mimatusexportcache)

**PSR-6 Cache without deserialization speeded-up with OPcache**

This cache package aim to target small niche use-cases when deserialization of stored data can have significant performance impact and when data stored in cache are updated rarely (or never, mainly because of write [performance](#performance)).

🛠 Installation
--------------

[](#-installation)

```
composer require mimatus/export-cache
```

It's highly recommanded to enable OPcache for best [performance](#performance)

Usage
-----

[](#usage)

### Use when ...

[](#use-when-)

- [OPcache](https://www.php.net/manual/en/book.OPcache.php) is enabled
- cached data are rarely changing (too frequent changes might lead to periodical reset of the OPcache memory)
- needs cache shared by PHP processes

### Don't use when...

[](#dont-use-when)

- basically in any other use-case which is not in [Use when ... section](#use-when) 😅

### Example

[](#example)

```
use MiMatus\ExportCache\ExportCache;

$storagePath = sys_get_temp_dir() . \DIRECTORY_SEPARATOR . 'export-cache';
$cache = new ExportCache($storagePath);
$closure = function () {
    return 'data'
};

$cache->set('key0', 'data', new DateInterval('P1D'));
$cache->set('key1', ['data']);
$cache->set('key2', $closure);
$cache->set('key3', 'expired data', new DateInterval('P1S'));

sleep(2);

assert($cache->get('key0') === 'data');
assert($cache->get('key1') === ['data']);
assert($cache->get('key2')() === 'data');
assert($cache->get('key3') === null);
```

### Data limitations

[](#data-limitations)

Thanks to [brick/varexporter](https://github.com/brick/varexporter) which is used for data serialization, it's possible to cache almost any PHP value, even closures, however with some [limitations](https://github.com/brick/varexporter#limitations):

- PHP Internal objects - SplFileInfo, XMLReader, etc.
- objects with circular references
- annonymous classes
- eval()'d or same line declared Closures, [more info](https://github.com/brick/varexporter#caveats)

Concurrency
-----------

[](#concurrency)

- Dirty Reads
- Lost Updates
- Phantom read
- Non-repeatable Reads - WIP

Performance - WIP
-----------------

[](#performance---wip)

Read [![](bench-read.png)](bench-read.png)Write [![](bench-write.png)](bench-write.png)To see full results use:

```
make build
make benchmark
```

`Requires: docker`

💌 Credits
---------

[](#-credits)

- serialization - [brick/varexporter](https://github.com/brick/varexporter)

Similar projects
----------------

[](#similar-projects)

- [Symfony's PHPFileAdapter](https://github.com/symfony/cache/blob/6.3/Adapter/PhpFilesAdapter.php)

###  Health Score

12

—

LowBetter than 0% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity21

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/943f580788acea907fe6435ad5ca785487d02039ee3f29c92b4554cff4e210e0?d=identicon)[MiMatus](/maintainers/MiMatus)

---

Top Contributors

[![MiMatus](https://avatars.githubusercontent.com/u/52460843?v=4)](https://github.com/MiMatus "MiMatus (8 commits)")

### Embed Badge

![Health badge](/badges/mimatus-export-cache/health.svg)

```
[![Health](https://phpackages.com/badges/mimatus-export-cache/health.svg)](https://phpackages.com/packages/mimatus-export-cache)
```

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

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