Adapters

All adapters implement the PSR-6 \Psr\Cache\CacheItemPoolInterface and can be used as standalone cache pools.

ApcuAdapter

Requires the APCu extension is loaded and enabled.

<?php

use SonsOfPHP\Componenet\Cache\Adapter\ApcuAdapter;

$cache = new ApcuAdapter();

// You can set a default TTL in seconds and Marshaller as well.
$cache = new ApcuAdapter(60, new CustomMarshaller());

ArrayAdapter

Stores cache items in an internal PHP array.

<?php

use SonsOfPHP\Componenet\Cache\Adapter\ArrayAdapter;

$cache = new ArrayAdapter();

ChainAdapter

The Chain Adapter will take one or more adapters. It will WRITE to all adapters and will READ from each adapter until it finds a hit and return that cache item.

FilesystemAdapter

Stores cache files on disk

NullAdapter

Mainly used for testing, however you could have some checks in place and if those checks fail, you could fallback to this adapter.

Last updated

Was this helpful?