From 2dc53c52700695b9f9b23c0c0b43f3dea6de9504 Mon Sep 17 00:00:00 2001 From: Brock H Caldwell Date: Sun, 22 Jun 2025 22:08:08 -0500 Subject: [PATCH] feat: tags torrentio cache --- src/Torrentio/Client/Torrentio.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Torrentio/Client/Torrentio.php b/src/Torrentio/Client/Torrentio.php index 109012f..d9fef60 100644 --- a/src/Torrentio/Client/Torrentio.php +++ b/src/Torrentio/Client/Torrentio.php @@ -10,8 +10,8 @@ use App\Torrentio\Exception\TorrentioRateLimitException; use GuzzleHttp\Client; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\Attribute\Autowire; -use Symfony\Contracts\Cache\CacheInterface; use Symfony\Contracts\Cache\ItemInterface; +use Symfony\Contracts\Cache\TagAwareCacheInterface; class Torrentio { @@ -23,7 +23,7 @@ class Torrentio public function __construct( #[Autowire(env: 'REAL_DEBRID_KEY')] private string $realDebridKey, - private CacheInterface $cache, + private TagAwareCacheInterface $cache, private LoggerInterface $logger, ) { $this->searchUrl = str_replace('{realDebridKey}', $this->realDebridKey, $this->baseUrl); @@ -36,8 +36,9 @@ class Torrentio { $cacheKey = "torrentio.{$imdbCode}"; - $results = $this->cache->get($cacheKey, function (ItemInterface $item) use ($imdbCode) { + $results = $this->cache->get($cacheKey, function (ItemInterface $item) use ($imdbCode, $type) { $item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0)); + $item->tag(['torrentio', $type, $imdbCode]); try { $response = $this->client->get("$this->searchUrl/$imdbCode.json"); return json_decode( @@ -63,6 +64,7 @@ class Torrentio $cacheKey = "torrentio.$imdbId.$season.$episode"; $results = $this->cache->get($cacheKey, function (ItemInterface $item) use ($imdbId, $season, $episode) { $item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0)); + $item->tag(['torrentio', 'tvshows', 'torrentio.tvshows', $imdbId, "torrentio.$imdbId", "$imdbId.$season", "torrentio.$imdbId.$season", "$imdbId.$season.$episode", "torrentio.$imdbId.$season.$episode"]); try { $response = $this->client->get("$this->searchUrl/$imdbId:$season:$episode.json"); return json_decode(