コード例 #1
0
 /**
  * @param Config $config
  *
  * @return <Some Connection>
  */
 public function getAdapter(Config $config)
 {
     $class = sprintf('\\Pcelta\\Doctrine\\Cache\\Factory\\%s', $config->getAdapterName());
     if (!class_exists($class)) {
         throw new InvalidCacheConfig('');
     }
     $this->factory = new $class();
     return $this->factory->create($config);
 }
コード例 #2
0
 /**
  * @param array $cacheSettings
  *
  * @return CacheProvider
  *
  * @throws InvalidCacheConfig
  */
 public function create(array $cacheSettings)
 {
     $config = new Config($cacheSettings);
     $class = sprintf('\\Pcelta\\Doctrine\\Cache\\Factory\\%sFactory', $config->getAdapterName());
     if (!class_exists($class)) {
         throw new InvalidCacheConfig('Adapter not found');
     }
     /* @var Factory\AbstractFactory $factory */
     $this->factory = new $class();
     return $this->factory->create($config);
 }
コード例 #3
0
 /**
  * @param Config $config
  *
  * @return bool
  */
 protected function isValidConfig(Config $config)
 {
     $settings = $config->getSettings();
     if (!isset($settings['host'])) {
         return false;
     }
     if (!isset($settings['port'])) {
         return false;
     }
     return true;
 }
コード例 #4
0
 /**
  * @param array $cacheSettings
  *
  * @return CacheProvider
  */
 public function create(array $cacheSettings)
 {
     $config = new Config($cacheSettings);
     $cacheClassName = sprintf($config->getAdapterNamespace(), $config->getAdapterName());
     if (!class_exists($cacheClassName)) {
         throw new InvalidCacheConfigException('Cache Adapter Not Supported!');
     }
     $cacheProvider = new $cacheClassName();
     if ($config->isConnectable() === true) {
         $this->addConnection($cacheProvider, $config);
     }
     return $cacheProvider;
 }
コード例 #5
0
 /**
  * @param Config $config
  *
  * @return CacheProvider
  *
  * @throws InvalidCacheConfigException
  */
 public function create(Config $config)
 {
     $this->config = $config;
     $cacheClassName = sprintf($config->getAdapterNamespace(), $this->config->getAdapterName());
     if (!class_exists($cacheClassName)) {
         throw new InvalidCacheConfig('Cache Adapter Not Supported!');
     }
     /** @var CacheProvider $cacheProvider */
     $cacheProvider = new $cacheClassName();
     if (!$this->isValidConfig($this->config)) {
         throw new InvalidCacheConfig('Options Not Supported Passed');
     }
     return $this->decorateWithConnectable($cacheProvider);
 }
コード例 #6
0
 /**
  * @param Config $config
  *
  * @return \Redis
  */
 public function create(Config $config)
 {
     $redis = new \Redis();
     $redis->connect($config->getHost(), $config->getPort());
     return $redis;
 }
コード例 #7
0
 /**
  * @param Config $config
  *
  * @return \Memcache
  *
  * @throws ModuleIsNotInstalled
  */
 public function create(Config $config)
 {
     $memcache = new \Memcache();
     $memcache->connect($config->getHost(), $config->getPort());
     return $memcache;
 }
コード例 #8
0
 /**
  * @param Config $config
  *
  * @return \Memcached
  */
 public function create(Config $config)
 {
     $memcached = new \Memcached();
     $memcached->addServer($config->getHost(), $config->getPort());
     return $memcached;
 }