Revision: Fri, 31 May 2024 16:10:39 GMT
v1.0 – outdated
This version of the documentation is outdated. Consider upgrading your project to Spiral Framework 3.12
Edit this page

Cache Bridges

Spiral utilizes PSR-16 (ORM) and PSR-6 (psr7-middlewares) protocols to allow your application to communicate with cache engines.

You are able to choose any caching library which support this mechanisms. To enable cache support in application create PSR interface binding to your implementation or factory:

use Psr\SimpleCache\CacheInterface;

class CacheBootloader extends Bootloader
    const SINGLETONS = [
        CacheInterface::class => [self::class, 'makeCache']

    protected function makeCache(): CacheItemPoolInterface
        return new MyCache();

Existed Bridges

Take a look at existed module spiral/phpfastcache which creates bridge to library and adds cache configuration into your application.

$ composer require spiral/phpfastcache
$ spiral register spiral/phpfastcache

Add bootloader Spiral/PhpFastCache/CacheBootloader to enable caching.