corollarium/psr6-profilecachepool

PSR-6 兼容的缓存池,用于分析缓存访问、命中和未命中。

v1.0.3 2016-09-27 20:25 UTC

This package is auto-updated.

Last update: 2024-09-10 04:25:13 UTC


README

PSR-6 兼容的缓存池,用于分析缓存访问、命中和未命中。由 Corollarium 开发。

Composer

composer require corollarium/psr6-profilecachepool

如何使用它

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

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

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

您会得到类似以下内容

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

聚合结果

使用多个缓存适配器?轻松获取聚合结果。

$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);