Closed
Description
Symfony version(s) affected
6.0
Description
Hi 👋
I wanted to add some cache on my database, and try the pdo adapter.
As the doctrine_dbal
wasn't yet mentionned in the doc (fixed here), I added the cache.adapter.pdo
in a new pool, fetch this pool in a service and try to use it. Got an error while the adapter try to initialize :
How to reproduce
Create a little project
composer create-project symfony/skeleton cacheIssue
cd cacheIssue
composer req orm
Config the cache
# config/packages/cache.yaml
framework:
cache:
pools:
db.cache:
adapter: cache.adapter.pdo
Use it in a new commmand
<?php
namespace App\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Contracts\Cache\CacheInterface;
#[AsCommand(
name: 'app:cache-test',
)]
class CacheTestCommand extends Command
{
public function __construct(private CacheInterface $dbCache)
{
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$value = $this->dbCache->get('app.hello', fn () => 'Hello from cache');
$output->writeln($value);
return Command::SUCCESS;
}
}
And run it
php bin/console app:cache-test
Possible Solution
Change the default value of default_pdo_provider
, whereas I'm not sure what to put here by default if we can't pass anymore the doctrine Connection.
Additional Context
I'm aware now that my mistake was to use this adapter instead cache.adapter.doctrine_dbal
in such context, but I think the remaining link between doctrine connection and this pdo adapter should not longer be here by default.