From f7c3e5bf4ad43389bf8d58d2c4aaf16b81cbce00 Mon Sep 17 00:00:00 2001 From: Yassine Doghri Date: Thu, 24 Feb 2022 16:08:24 +0000 Subject: [PATCH] fix(cache): delete posts and comments pages cache when updating platform links remove cache when adding comment and replies as well fixes #169 --- app/Controllers/EpisodeCommentController.php | 1 + app/Models/EpisodeCommentModel.php | 6 ++++++ app/Models/PlatformModel.php | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/app/Controllers/EpisodeCommentController.php b/app/Controllers/EpisodeCommentController.php index fbb3452f..d0c46cf1 100644 --- a/app/Controllers/EpisodeCommentController.php +++ b/app/Controllers/EpisodeCommentController.php @@ -87,6 +87,7 @@ class EpisodeCommentController extends BaseController '_', array_filter([ 'page', + "episode#{$this->episode->id}", "comment#{$this->comment->id}", service('request') ->getLocale(), diff --git a/app/Models/EpisodeCommentModel.php b/app/Models/EpisodeCommentModel.php index c8830c16..d54d0966 100644 --- a/app/Models/EpisodeCommentModel.php +++ b/app/Models/EpisodeCommentModel.php @@ -122,6 +122,12 @@ class EpisodeCommentModel extends UuidModel $this->db->transComplete(); + // delete podcast and episode pages cache + cache() + ->deleteMatching('page_podcast#' . $comment->episode->podcast_id . '*'); + cache() + ->deleteMatching('page_episode#' . $comment->episode_id . '*'); + return $newCommentId; } diff --git a/app/Models/PlatformModel.php b/app/Models/PlatformModel.php index fb0be902..e58c7ab3 100644 --- a/app/Models/PlatformModel.php +++ b/app/Models/PlatformModel.php @@ -198,5 +198,10 @@ class PlatformModel extends Model // delete localized podcast page cache cache() ->deleteMatching("page_podcast#{$podcastId}*"); + // delete post and episode comments pages cache + cache() + ->deleteMatching('page_post*'); + cache() + ->deleteMatching('page_episode#*'); } }