symfony-swap
symfony-swap copied to clipboard
Can't use a custom cache provider
Test on Symfony 4.4.21.
After installing symfony-swap and his dependencies, i created a custom cache provider in the same way than recommanded at https://github.com/florianv/swap/blob/master/doc/readme.md#cacheby using a PRedis Client.
I used it after in the same way than https://github.com/florianv/symfony-swap/blob/master/Resources/doc/index.md.
This is the configuration i have : config/services.yaml :
services:
# Create a psr-6 CachePool with our Predis Client
redis.cache_pool:
class: Cache\Adapter\Predis\PredisCachePool
arguments:
$cache: "@snc_redis.default"
# Create a psr-16 CacheInterface
redis.psr16.adapter:
class: Cache\Bridge\SimpleCache\SimpleCacheBridge
arguments:
$cacheItemPool: "@redis.cache_pool"
# Autowire
Swap\Swap: "@florianv_swap.swap"
Cache\Bridge\SimpleCache\SimpleCacheBridge: "@redis.psr16.adapter"
config/packages/florianv_swap.yaml :
florianv_swap:
cache:
ttl: 86400
type: redis.psr16.adapter # "redis.psr16.adapter" or "@redis.psr16.adapter" don't work either
providers:
european_central_bank: ~
I got this error :
Unexpected swap cache type 'redis.psr16.adapter"
at florianv/swap-bundle/DependencyInjection/FlorianvSwapExtension.php
line 116
it look like that the $container as no definition for the "redis.psr16.adapter" in FlorianvSwapExtension on line 108.
How to fix this error ?
Additional clarification, when i build a new Swap with the custom cache : it's working well
$swap = (new Builder(['cache_ttl' => 3600, 'cache_key_prefix' => 'myapp-']))
->add('european_central_bank', [])
->useSimpleCache($simpleCacheBridge) // $simpleCacheBridge : Cache\Bridge\SimpleCache\SimpleCacheBridge
->build();
Same problem here.
Hi, this is due to this condition here: https://github.com/florianv/symfony-swap/blob/master/DependencyInjection/FlorianvSwapExtension.php#L83 and here: https://github.com/florianv/symfony-swap/blob/master/DependencyInjection/FlorianvSwapExtension.php#L108
In case you'd like to debug the issue ;) Thanks!