File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Cache \AdapterBundle \Factory ;
4+
5+ use Cache \Adapter \Doctrine \DoctrineCachePool ;
6+ use Cache \Adapter \Redis \RedisCachePool ;
7+ use Doctrine \Common \Cache \RedisCache ;
8+ use Predis \Client ;
9+
10+ class DoctrineRedisFactory implements AdapterFactoryInterface
11+ {
12+ public function createAdapter (array $ options = array ())
13+ {
14+ if (!class_exists ('Cache\Adapter\Doctrine\DoctrineCachePool ' )) {
15+ throw new \LogicException ('You must install the "cache/doctrine-adapter" package to use the "doctrine_redis" provider. ' );
16+ }
17+
18+ // TODO validate the options with symfony options resolver
19+ // TODO get ip, port and protocol from options.
20+
21+ $ redis = new \Redis ();
22+ $ redis ->connect ('127.0.0.1 ' , '6379 ' );
23+
24+ $ client = new RedisCache ();
25+ $ client ->setRedis ($ redis );
26+
27+ return new DoctrineCachePool ($ client );
28+ }
29+ }
Original file line number Diff line number Diff line change @@ -14,3 +14,7 @@ parameters:
1414services :
1515 cache.factory.redis :
1616 class : Cache\AdapterBundle\Factory\RedisFactory
17+
18+ cache.factory.doctrine_redis :
19+ class : Cache\AdapterBundle\Factory\DoctrineRedisFactory
20+
You can’t perform that action at this time.
0 commit comments