XUtils

Laminas Cache

Another caching library.


Standalone

If this component is used without laminas-mvc or mezzio, a PSR-11 container to fetch services, adapters, plugins, etc. is needed.

The easiest way would be to use laminas-config-aggregator along with laminas-servicemanager.

use Laminas\Cache\ConfigProvider;
use Laminas\Cache\Service\StorageAdapterFactoryInterface;
use Laminas\Cache\Storage\Adapter\Memory;
use Laminas\ConfigAggregator\ConfigAggregator;
use Laminas\ServiceManager\ServiceManager;

$config = (new ConfigAggregator([
    ConfigProvider::class,
]))->getMergedConfig();

$dependencies = $config['dependencies'];

$container = new ServiceManager($dependencies);

/** @var StorageAdapterFactoryInterface $storageFactory */
$storageFactory = $container->get(StorageAdapterFactoryInterface::class);

$storage = $storageFactory->create(Memory::class);

$storage->setItem('foo', 'bar');

Benchmarks

We provide scripts for benchmarking laminas-cache using the PHPBench framework; these can be found in the benchmark/ directory of each storage adapter.

To execute the benchmarks you can run the following command:

$ vendor/bin/phpbench run --report=aggregate

Articles

  • coming soon...