Esempio n. 1
0
 protected static function connect($servers)
 {
     $memcache = new \Memcached();
     foreach ($servers as $server) {
         $memcache->addServer($server['host'], $server['port'], $server['weight']);
     }
     if ($memcache->getVersion() === false) {
         throw new \Exception('Could not establish memcached connection.');
     }
     return $memcache;
 }
Esempio n. 2
0
 /**
  * Create a new cache driver instance.
  *
  * @param  string  $driver
  * @return Cache\Drivers\Driver
  */
 protected static function factory($driver)
 {
     if (isset(static::$registrar[$driver])) {
         $resolver = static::$registrar[$driver];
         return $resolver();
     }
     switch ($driver) {
         case 'apc':
             return new Cache\Drivers\APC(Config::get('cache.key'));
         case 'file':
             return new Cache\Drivers\File(path('storage') . 'cache' . DS);
         case 'memcached':
             return new Cache\Drivers\Memcached(Memcached::connection(), Config::get('cache.key'));
         case 'memory':
             return new Cache\Drivers\Memory();
         case 'redis':
             return new Cache\Drivers\Redis(Redis::db());
         case 'database':
             return new Cache\Drivers\Database(Config::get('cache.key'));
         case 'wincache':
             return new Cache\Drivers\WinCache(Config::get('cache.key'));
         default:
             throw new \Exception("Cache driver {$driver} is not supported.");
     }
 }
 /**
  * Create a new cache driver instance.
  *
  * @param  string  $driver
  * @return Driver
  */
 protected static function factory($driver)
 {
     switch ($driver) {
         case 'apc':
             return new Drivers\APC(Config::get('cache.key'));
         case 'file':
             return new Drivers\File(CACHE_PATH);
         case 'memcached':
             return new Drivers\Memcached(Memcached::instance(), Config::get('cache.key'));
         case 'redis':
             return new Drivers\Redis(Redis::db());
         default:
             throw new \DomainException("Cache driver {$driver} is not supported.");
     }
 }