Symfony Cache with Database


The Symfony Cache component has a large number of possible adapters for cached information.

For caching in the database, you can use the following PdoAdapter for Doctrine and configure the following dimensions:

#config/packages/framework.yaml
framework:
    cache:
        pools:
            app:
                adapter: AppCache
#config/services.yaml
AppCache:
  class: Symfony\Component\Cache\Adapter\PdoAdapter
  arguments:
    - '@doctrine.dbal.default_connection'

Symfony thus generates a database table within the default database connection for the cache entries.

This has particularly performance gains and is clearer compared to the default file system variant. This is especially recommended for a Docker environment, because the slow file system does not need to be diluted.

Comments are closed.