Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Cache] Pdo adapter is still linked with doctrine connection #45407

Copy link
Copy link
Closed
@Jibbarth

Description

@Jibbarth
Issue body actions

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 :

image

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.