mimatus/export-cache
Composer 安装命令:
composer require mimatus/export-cache
包简介
PSR-6 Cache without deserialization speeded-up with OPcache
README 文档
README
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).
🛠 Installation
composer require mimatus/export-cache
It's highly recommanded to enable OPcache for best performance
Usage
Use when ...
- OPcache 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...
- basically in any other use-case which is not in Use when ... section 😅
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
Thanks to brick/varexporter which is used for data serialization, it's possible to cache almost any PHP value, even closures, however with some limitations:
- PHP Internal objects - SplFileInfo, XMLReader, etc.
- objects with circular references
- annonymous classes
- eval()'d or same line declared Closures, more info
Concurrency
- Dirty Reads
- Lost Updates
- Phantom read
- Non-repeatable Reads - WIP
Performance - WIP
To see full results use:
make build make benchmark
Requires: docker
💌 Credits
- serialization - brick/varexporter
Similar projects
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-22

