A PSR6 compatible cache pool for profiling cache access, hits and misses.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
ProfileCachePool.php
README.md
composer.json

README.md

PSR6-ProfileCachePool

A PSR6 compatible cache pool for profiling cache access, hits and misses. Developed by Corollarium.

Composer

composer require corollarium/psr6-profilecachepool

How to use it

$pool = new \Cache\Wrapper\ProfileCachePool(new MyRealAdapterPool());

// use normally
$pool->getItem('foo');

// print cute statistics in the end
$pool->reportHTML();

You get something like:

Cache Profile Summary: accessed=>100 / missed=>39 / deleted=>12 / cleaned=>0 / saved=>15 /

Aggregating results

Using multiple cache adapters? It's easy to get the aggregated results.

$pool1 = new \Cache\Wrapper\ProfileCachePool(new MyRealAdapterPool());
$pool2 = new \Cache\Wrapper\ProfileCachePool(new MyOtherAdapterPool());

// use normally
$pool1->getItem('foo');
$pool2->getItem('bar');

// merge statistics from several pools together
$mergedStatistics = \Cache\Wrapper\ProfileCachePool::mergeProfileSummaries([$pool1, $pool2]);

// print cute statistics in the end
\Cache\Wrapper\ProfileCachePool::summaryHTML($mergedStatistics);