File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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 \Memcache \MemcacheCachePool ;
15+ use Memcache ;
16+ use Symfony \Component \OptionsResolver \OptionsResolver ;
17+
18+ /**
19+ * @author Nicholas Ruunu <nicholas@ruu.nu>
20+ */
21+ class MemcacheFactory extends AbstractAdapterFactory
22+ {
23+ protected static $ dependencies = [
24+ ['requiredClass ' => 'Cache\Adapter\Memcache\MemcacheCachePool ' , 'packageName ' => 'cache/memcache-adapter ' ],
25+ ];
26+
27+ /**
28+ * {@inheritdoc}
29+ */
30+ public function getAdapter (array $ config )
31+ {
32+ $ client = new Memcache ();
33+ $ client ->connect ($ config ['host ' ], $ config ['port ' ]);
34+
35+ return new MemcacheCachePool ($ client );
36+ }
37+
38+ /**
39+ * {@inheritdoc}
40+ */
41+ protected static function configureOptionResolver (OptionsResolver $ resolver )
42+ {
43+ $ resolver ->setDefaults ([
44+ 'host ' => '127.0.0.1 ' ,
45+ 'port ' => 11211 ,
46+ ]);
47+
48+ $ resolver ->setAllowedTypes ('host ' , ['string ' ]);
49+ $ resolver ->setAllowedTypes ('port ' , ['string ' , 'int ' ]);
50+ }
51+ }
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ protected static function configureOptionResolver(OptionsResolver $resolver)
4141 {
4242 $ resolver ->setDefaults ([
4343 'host ' => '127.0.0.1 ' ,
44- 'port ' => ' 6379 ' ,
44+ 'port ' => 11211 ,
4545 ]);
4646
4747 $ resolver ->setAllowedTypes ('host ' , ['string ' ]);
You can’t perform that action at this time.
0 commit comments