Use Symfony app cache as a service

I you wan’t to use Symfony app cache (with redis for example), this is a simple how-to:

# config_prod.yml
app: cache.adapter.redis
default_redis_provider: "redis://%redis_host%"

Then use it as a service with `` name.

When injected in your service, you will retrieve an Symfony\Component\Cache\Adapter\TraceableAdapter. But when available, best practise is to typint it as the PSR’s interface.

public function __construct(
Psr\Cache\CacheItemPoolInterface $cacheItemPool

Then all the methods defined by the PSR are available.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.