Skip to content

Commit 073c5bd

Browse files
committed
Making router psr6
1 parent 1e9edc9 commit 073c5bd

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Routing/Router.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Aequasi\Bundle\CacheBundle\Routing\Matcher\CacheUrlMatcher;
1212
use Aequasi\Cache\CachePool;
13+
use Psr\Cache\CacheItemPoolInterface;
1314
use Symfony\Bundle\FrameworkBundle\Routing\Router as BaseRouter;
1415
use Symfony\Component\DependencyInjection\ContainerInterface;
1516
use Symfony\Component\Routing\RequestContext;
@@ -21,13 +22,15 @@
2122
*/
2223
class 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

0 commit comments

Comments
 (0)