mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-11 02:36:42 +02:00
fix(cache): add locale for podcast and episode pages + clear some persisting cache in models
fixes #42, #61
This commit is contained in:
parent
a354940e5e
commit
9cec8a81cc
6 changed files with 209 additions and 106 deletions
|
|
@ -76,8 +76,7 @@ class PlatformModel extends Model
|
|||
|
||||
public function savePlatformLinks($podcastId, $platformLinksData)
|
||||
{
|
||||
cache()->delete("podcast{$podcastId}_platforms");
|
||||
cache()->delete("podcast{$podcastId}_platformLinks");
|
||||
$this->clearCache($podcastId);
|
||||
|
||||
// Remove already previously set platforms to overwrite them
|
||||
$this->db
|
||||
|
|
@ -109,12 +108,39 @@ class PlatformModel extends Model
|
|||
|
||||
public function removePlatformLink($podcastId, $platformId)
|
||||
{
|
||||
cache()->delete("podcast{$podcastId}_platforms");
|
||||
cache()->delete("podcast{$podcastId}_platformLinks");
|
||||
$this->clearCache($podcastId);
|
||||
|
||||
return $this->db->table('platform_links')->delete([
|
||||
'podcast_id' => $podcastId,
|
||||
'platform_id' => $platformId,
|
||||
]);
|
||||
}
|
||||
|
||||
public function clearCache($podcastId)
|
||||
{
|
||||
cache()->delete("podcast{$podcastId}_platforms");
|
||||
cache()->delete("podcast{$podcastId}_platformLinks");
|
||||
|
||||
// delete localized podcast page cache
|
||||
$episodeModel = new EpisodeModel();
|
||||
$years = $episodeModel->getYears($podcastId);
|
||||
$seasons = $episodeModel->getSeasons($podcastId);
|
||||
$supportedLocales = config('App')->supportedLocales;
|
||||
|
||||
foreach ($years as $year) {
|
||||
foreach ($supportedLocales as $locale) {
|
||||
cache()->delete(
|
||||
"page_podcast{$podcastId}_{$year['year']}_{$locale}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($seasons as $season) {
|
||||
foreach ($supportedLocales as $locale) {
|
||||
cache()->delete(
|
||||
"page_podcast{$podcastId}_season{$season['season_number']}_{$locale}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue