Description
Symfony version(s) affected: 3.4.15
Description
I tried to create a cache pool with frameworkBundle config for a PdoAdapter but couldnt get it to work.
How to reproduce
I defined the adapter service:
cache.adapter_pdo:
class: Symfony\Component\Cache\Adapter\PdoAdapter
public: true
arguments:
- 'mysql:host=%database_host%;dbname=%database_name%'
- 'namespace-'
- '%cache.ttl%'
- db_username: '%database_user%'
db_password: '%database_password%'
And tried to define the cache pool with the framework bundle:
pdo_cache:
adapter: 'cache.adapter_pdo'
public: true
default_lifetime: '%cache.ttl%'
This leads to this error:
Symfony\Component\Cache\Exception\InvalidArgumentException: Cache key must be string, "integer" given
So somehow the ttl is set as the namespace argument in the PdoAdapter in the container.
Further when i tag the adapter as cache.pool while not using the bundle config it also stops working:
booking_cache:
class: Symfony\Component\Cache\Adapter\PdoAdapter
public: true # only for tests
arguments:
- 'mysql:host=%database_host%;dbname=%database_name%'
- 'booking-'
- '%booking_cache.ttl%'
- db_username: '%database_user%'
db_password: '%database_password%'
tags: ['cache.pool']
When just using a service definition for the cachepool everything is fine.
But the profiler doesnt show any information on this cache.
Possible Solution
I guess the argument replacement in FrameworkBundle/DependencyInjection/Compiler/CachePoolPass.php:85
is not accurate.
Or i did not understand how to use the cache pool config here, then please explain how to achieve this.
And we should update the docs accordingly.
Additional context
Another occurence of this problem i found here:
https://stackoverflow.com/questions/47270162/symfony3-cache-component-pool-definition