From 83583e0d3d8e1c62050ce1f5ca2d5b231c913d36 Mon Sep 17 00:00:00 2001 From: Serreau Jovann Date: Thu, 26 Mar 2026 12:50:13 +0100 Subject: [PATCH] Enable Doctrine L2 cache and add Redis cache pools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Doctrine Second Level Cache (NONSTRICT_READ_WRITE) on: - Event, User, Category, Billet, BilletDesign - Default region: 1h TTL, short_lived region: 5min TTL Redis cache pools added: - app.cache.events (30min) — for event listings - app.cache.homepage (5min) — for homepage data - doctrine.result_cache_pool — DQL result cache via Redis - doctrine.system_cache_pool — metadata/query cache All pools backed by Redis DB 2. Reduces DB queries significantly for read-heavy pages (event listings, user profiles, categories). Co-Authored-By: Claude Opus 4.6 (1M context) --- config/packages/cache.yaml | 10 ++++++++++ config/packages/doctrine.yaml | 13 +++++-------- src/Entity/Billet.php | 1 + src/Entity/BilletDesign.php | 1 + src/Entity/Category.php | 1 + src/Entity/Event.php | 1 + src/Entity/User.php | 1 + 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/config/packages/cache.yaml b/config/packages/cache.yaml index c23aecc..4cf42e8 100644 --- a/config/packages/cache.yaml +++ b/config/packages/cache.yaml @@ -12,6 +12,16 @@ framework: stats.cache: adapter: cache.app default_lifetime: 600 + app.cache.events: + adapter: cache.app + default_lifetime: 1800 + app.cache.homepage: + adapter: cache.app + default_lifetime: 300 + doctrine.result_cache_pool: + adapter: cache.app + doctrine.system_cache_pool: + adapter: cache.system when@test: framework: diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml index eaebe6b..5c06639 100644 --- a/config/packages/doctrine.yaml +++ b/config/packages/doctrine.yaml @@ -47,11 +47,8 @@ when@prod: cache_driver: type: pool pool: doctrine.result_cache_pool - - framework: - cache: - pools: - doctrine.result_cache_pool: - adapter: cache.app - doctrine.system_cache_pool: - adapter: cache.system + short_lived: + lifetime: 300 + cache_driver: + type: pool + pool: doctrine.result_cache_pool diff --git a/src/Entity/Billet.php b/src/Entity/Billet.php index 92cdb86..7eaddae 100644 --- a/src/Entity/Billet.php +++ b/src/Entity/Billet.php @@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\File\File; use Vich\UploaderBundle\Mapping\Attribute as Vich; #[ORM\Entity(repositoryClass: BilletRepository::class)] +#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE')] #[Vich\Uploadable] class Billet { diff --git a/src/Entity/BilletDesign.php b/src/Entity/BilletDesign.php index 1663a02..99aef90 100644 --- a/src/Entity/BilletDesign.php +++ b/src/Entity/BilletDesign.php @@ -6,6 +6,7 @@ use App\Repository\BilletDesignRepository; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: BilletDesignRepository::class)] +#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE')] class BilletDesign { #[ORM\Id] diff --git a/src/Entity/Category.php b/src/Entity/Category.php index 4d82e64..dbbd855 100644 --- a/src/Entity/Category.php +++ b/src/Entity/Category.php @@ -6,6 +6,7 @@ use App\Repository\CategoryRepository; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: CategoryRepository::class)] +#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE')] class Category { #[ORM\Id] diff --git a/src/Entity/Event.php b/src/Entity/Event.php index 609cc37..3837f37 100644 --- a/src/Entity/Event.php +++ b/src/Entity/Event.php @@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\File\File; use Vich\UploaderBundle\Mapping\Attribute as Vich; #[ORM\Entity(repositoryClass: EventRepository::class)] +#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE')] #[Vich\Uploadable] class Event { diff --git a/src/Entity/User.php b/src/Entity/User.php index 5bf08bb..c68aa23 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -13,6 +13,7 @@ use Vich\UploaderBundle\Mapping\Attribute as Vich; #[ORM\Entity(repositoryClass: UserRepository::class)] #[ORM\Table(name: '`user`')] +#[ORM\Cache(usage: 'NONSTRICT_READ_WRITE')] #[UniqueEntity(fields: ['email'], message: 'Un compte existe déjà avec cet email.')] #[Vich\Uploadable] class User implements UserInterface, PasswordAuthenticatedUserInterface