use Spiral\Boot\Bootloader\Bootloader;
use Spiral\Boot\EnvironmentInterface;
use Spiral\Cache\CacheStorageRegistryInterface;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Psr16Cache;
final class RedisCacheBootloader extends Bootloader
{
public function boot(CacheStorageRegistryInterface $cacheRegistry, EnvironmentInterface $env): void
{
$cacheRegistry->set(
name: 'redis',
cache: new Psr16Cache(
pool: new RedisAdapter(
redis: RedisAdapter::createConnection($env->get('REDIS_DSN'))
),
)
);
}
}
User can set custom cache in bootloader.
Example for redis
For now my cache config not looks pretty.