33namespace App \Controller ;
44
55use App \Entity \AppRelease ;
6- use App \Service \ReleaseApi ;
76use Doctrine \Persistence \ManagerRegistry ;
87use Michelf \Markdown ;
8+ use Psr \Cache \CacheItemPoolInterface ;
99use Symfony \Bundle \FrameworkBundle \Controller \AbstractController ;
1010use Symfony \Component \HttpFoundation \Response ;
1111use Symfony \Component \Routing \Attribute \Route ;
@@ -20,11 +20,11 @@ class AppReleaseRSSFeedController extends AbstractController
2020 * http://api.qownnotes.org/rss/app-releases
2121 */
2222 #[Route('/rss/app-releases ' )]
23- public function appReleases (ManagerRegistry $ doctrine ): Response
23+ public function appReleases (ManagerRegistry $ doctrine, CacheItemPoolInterface $ cache ): Response
2424 {
25- $ cacheDriver = ReleaseApi:: getCacheDriver ( );
25+ $ cacheItem = $ cache -> getItem ( self :: CACHE_KEY );
2626
27- if (!$ cacheDriver -> contains ( self :: CACHE_KEY )) {
27+ if (!$ cacheItem -> isHit ( )) {
2828 $ projectUrl = 'https://www.qownnotes.org ' ;
2929
3030 $ xml = new \DOMDocument ('1.0 ' , 'UTF-8 ' ); // Create new DOM document.
@@ -117,9 +117,11 @@ public function appReleases(ManagerRegistry $doctrine): Response
117117
118118 $ xmlString = $ xml ->saveXML ();
119119
120- $ cacheDriver ->save (self ::CACHE_KEY , $ xmlString , 60 );
120+ $ cacheItem ->set ($ xmlString );
121+ $ cacheItem ->expiresAfter (60 );
122+ $ cache ->save ($ cacheItem );
121123 } else {
122- $ xmlString = $ cacheDriver -> fetch ( self :: CACHE_KEY );
124+ $ xmlString = $ cacheItem -> get ( );
123125 }
124126
125127 return new Response ($ xmlString , 200 , ['Content-Type ' => 'text/xml ' ]);
0 commit comments