symfony: [FrameworkBundle] missing integration of PSR-16 simple cache

Description
Cache pools can easily be configured in the framework bundle with

framework:
    cache:
        pools:
            cache.pool1:
                adapter: cache.adapter.redis
            cache.pool2:
                adapter: cache.adapter.redis

But all the cache services created only implement PSR-6 Psr\Cache\CacheItemPoolInterface. We would like to use PSR-16 Psr\SimpleCache\CacheInterface instead. Currently the only solution seems to be to wrap all the pools in an adapter like

services:
    cache.simple.pool1:
        class: Symfony\Component\Cache\Simple\Psr6Cache
        arguments: ['@cache.pool1']

    cache.simple.pool2
        class: Symfony\Component\Cache\Simple\Psr6Cache
        arguments: ['@cache.pool2']

This is quite cumbersome as we have alot of pools. It would be nice if the framework bundle provides a way to use SimpleCache directly. Maybe something like the following would create PSR-16 caches instead:

framework:
    cache:
        pools:
            cache.pool1:
                adapter: cache.adapter.redis
                simple: true
            cache.pool2:
                adapter: cache.adapter.redis
                simple: true

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

For what it worth I like the PSR-6. It’s not as simple as PSR-16 but actually PSR-16 has many drawbacks (the key is duplicated in the code, and it’s impossible to know if the item was hit). I always use PSR-6 and I’m teaching only this way.

The new CacheInterface is nice too and I like it too 😃 But it’s not a PSR 😕 I’m not sure it’s an issue.*

So for me : We should not talk about PSR-16 at all and only promote PSR-6 or the CacheInterface

And we can / should do that in 4.2, because that’s when the new CacheInterface will be available (which is both easy to use and powerful - best of both worlds)

The fact that this doesn’t exist is on purpose: the more choices we provide, the more confused people are. Here, PSR 16 doesn’t provide anything over PSR 6. With the new CacheInterface, PSR 16 is not the simplest alternatives if one thinks that’s where it fits. With this reasoning, I think we shouldn’t have a configuration helper for it.