ssch/typo3-psr-cache-adapter

Provide Adapters for TYPO3 to be compatible with PSR-6

Installs: 18 535

Dependents: 3

Suggesters: 0

Security: 0

Stars: 3

Watchers: 3

Forks: 1

Open Issues: 2

Type:typo3-cms-extension

v1.2.2 2023-12-08 11:29 UTC

README

Provide a PSR-6 and PSR-16 compatible cache adapter for the TYPO3 Caching Framework.

Usage

To ease the creation of a PSR-6 or PSR-16 compatible cache object the extension ships with two factories. One for PSR-6 and one for PSR-16.
Create either a PSR-6 or a PSR-16 compatible cache object with leveraging Symfony DI configuration:

use Psr\Cache\CacheItemPoolInterface;
use Ssch\Cache\Factory\Psr6Factory;
use MyNamespace\MyExtensionKey\Service\MyService;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $containerConfigurator): void {
    $services = $containerConfigurator->services();
    $services->defaults()
        ->autowire()
        ->private()
        ->autoconfigure();

    $services->set('cache.psr6.typo3_psr_cache_adapter_test', CacheItemPoolInterface::class)
        ->factory([service(Psr6Factory::class), 'create'])
        ->args(['typo3_psr_cache_adapter_test']);
    $services->set(MyService::class)
        ->args([service('cache.psr6.typo3_psr_cache_adapter_test')]);
};

Note the typo3_psr_cache_adapter_test. This is the cache identifier you have used to configure your TYPO3 Cache for the TYPO3 Caching Framework.