예제 #1
0
 /**
  * @param array $params
  *
  * @return \Memcache
  *
  * @throws ModuleIsNotInstalled
  */
 public function create(array $params)
 {
     if (!$this->isValidParams($params)) {
         throw new InvalidCacheConfig();
     }
     $memcache = new \Memcache();
     $memcache->connect($params['host'], $params['port']);
     return $memcache;
 }
예제 #2
0
 /**
  * @covers Dafiti\Silex\Cache\Factory\Memcache::create
  * @covers Dafiti\Silex\Cache\Factory\Memcache::isValidParams
  */
 public function testCreateShouldReturnMemcacheInstance()
 {
     $params = ['host' => '127.0.0.1', 'port' => 11211];
     $factory = new Memcache();
     if (!extension_loaded(Memcache::MODULE_NAME)) {
         $this->markTestSkipped('Memcache Module Is Not Installed');
         return;
     }
     $result = $factory->create($params);
     $this->assertInstanceOf('\\Memcache', $result);
 }