Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use a custom cache provider #45

Open
PetitGrigri opened this issue May 17, 2021 · 2 comments
Open

Can't use a custom cache provider #45

PetitGrigri opened this issue May 17, 2021 · 2 comments

Comments

@PetitGrigri
Copy link

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();
@stevenbrookes
Copy link
Contributor

Same problem here.

@florianv
Copy link
Owner

florianv commented Apr 4, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants