File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 1010
1111use Aequasi \Bundle \CacheBundle \Routing \Matcher \CacheUrlMatcher ;
1212use Aequasi \Cache \CachePool ;
13+ use Psr \Cache \CacheItemPoolInterface ;
1314use Symfony \Bundle \FrameworkBundle \Routing \Router as BaseRouter ;
1415use Symfony \Component \DependencyInjection \ContainerInterface ;
1516use Symfony \Component \Routing \RequestContext ;
2122 */
2223class Router extends BaseRouter
2324{
25+ const CACHE_LIFETIME = 604800 ; // a week
26+
2427 /**
2528 * @var ContainerInterface
2629 */
2730 protected $ container ;
2831
2932 /**
30- * @var CachePool
33+ * @var CacheItemPoolInterface
3134 */
3235 protected $ cache ;
3336
@@ -64,18 +67,20 @@ public function getRouteCollection()
6467 }
6568
6669 $ this ->collection = parent ::getRouteCollection ();
67- $ this ->cache ->saveItem ($ key , $ this ->collection , 60 * 60 * 24 * 7 );
70+ $ item = $ this ->cache ->getItem ($ key );
71+ $ item ->set ($ this ->collection )
72+ ->expiresAfter (self ::CACHE_LIFETIME );
6873 }
6974
7075 return $ this ->collection ;
7176 }
7277
7378 /**
74- * @param CachePool $cache
79+ * @param CacheItemPoolInterface $cache
7580 *
7681 * @return Router
7782 */
78- public function setCache (CachePool $ cache )
83+ public function setCache (CacheItemPoolInterface $ cache )
7984 {
8085 $ this ->cache = $ cache ;
8186
You can’t perform that action at this time.
0 commit comments