File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,10 +29,6 @@ class DoctrineRedisFactory extends AbstractAdapterFactory
2929 */
3030 public function getAdapter (array $ config )
3131 {
32- if (!class_exists ('Cache\Adapter\Doctrine\DoctrineCachePool ' )) {
33- throw new \LogicException ('You must install the "cache/doctrine-adapter" package to use the "doctrine_redis" provider. ' );
34- }
35-
3632 $ redis = new \Redis ();
3733 $ redis ->connect ($ config ['host ' ], $ config ['port ' ]);
3834
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of php-cache\adapter-bundle package.
5+ *
6+ * (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com>
7+ *
8+ * This source file is subject to the MIT license that is bundled
9+ * with this source code in the file LICENSE.
10+ */
11+
12+ namespace Cache \AdapterBundle \Factory ;
13+
14+ use Cache \Adapter \PhpRedis \PhpRedisCachePool ;
15+ use Symfony \Component \OptionsResolver \OptionsResolver ;
16+
17+ /**
18+ * @author Tobias Nyholm <tobias.nyholm@gmail.com>
19+ */
20+ class PhpRedisFactory extends AbstractAdapterFactory
21+ {
22+ protected static $ dependencies = [
23+ ['requiredClass ' => 'Cache\Adapter\PhpRedis\PhpRedisCachePool ' , 'packageName ' => 'cache/phpredis-adapter ' ],
24+ ];
25+
26+ /**
27+ * {@inheritdoc}
28+ */
29+ public function getAdapter (array $ config )
30+ {
31+ $ client = new \Redis ();
32+ $ client ->client ($ config ['host ' ], $ config ['port ' ]);
33+
34+ return new PhpRedisCachePool ($ client );
35+ }
36+
37+ /**
38+ * {@inheritdoc}
39+ */
40+ protected static function configureOptionResolver (OptionsResolver $ resolver )
41+ {
42+ $ resolver ->setDefaults ([
43+ 'host ' => '127.0.0.1 ' ,
44+ 'port ' => '6379 ' ,
45+ ]);
46+
47+ $ resolver ->setAllowedTypes ('host ' , ['string ' ]);
48+ $ resolver ->setAllowedTypes ('port ' , ['string ' , 'int ' ]);
49+ }
50+ }
You can’t perform that action at this time.
0 commit comments