original_string: public function store($name = null)
      {
          if (is_null($name)) {
              $name = $this->defaultStore;
          }
  
          if (isset($this->caches[$name])) {
              return $this->caches[$name];
          }
  
          $config = config('cache.stores.' . $name);
          if ($config === null) {
              throw new InvalidArgumentException('Cache store "' . $name . '" is not defined.');
          }
  
          if (!isset($config['driver'])) {
              throw new InvalidArgumentException('Cache driver for store "' . $name . '" is not specified.');
          }
  
          switch ($config['driver']) {
              case 'APCu':
                  $provider = new ApcuCache;
                  break;
              case 'Array':
                  $provider = new ArrayCache;
                  break;
              case 'File':
                  $provider = new FilesystemCache($config['path']);
                  break;
              case 'Memcached':
                  $memcached = new Memcached();
                  $memcached->addServer($config['host'], $config['port'], $config['weight']);
                  $provider = new MemcachedCache();
                  $provider->setMemcached($memcached);
                  break;
              case 'Redis':
                  $redis = new Redis;
                  $redis->connect($config['host'], $config['port'], $config['timeout']);
                  $provider = new RedisCache;
                  $provider->setRedis($redis);
                  break;
              default:
                  throw new InvalidArgumentException('Cache driver "' . $config['driver'] . '" is not supported.');
          }
  
          return $this->caches[$name] = new Cache($provider);
      }
code: public function store($name = null)
      {
          if (is_null($name)) {
              $name = $this->defaultStore;
          }
  
          if (isset($this->caches[$name])) {
              return $this->caches[$name];
          }
  
          $config = config('cache.stores.' . $name);
          if ($config === null) {
              throw new InvalidArgumentException('Cache store "' . $name . '" is not defined.');
          }
  
          if (!isset($config['driver'])) {
              throw new InvalidArgumentException('Cache driver for store "' . $name . '" is not specified.');
          }
  
          switch ($config['driver']) {
              case 'APCu':
                  $provider = new ApcuCache;
                  break;
              case 'Array':
                  $provider = new ArrayCache;
                  break;
              case 'File':
                  $provider = new FilesystemCache($config['path']);
                  break;
              case 'Memcached':
                  $memcached = new Memcached();
                  $memcached->addServer($config['host'], $config['port'], $config['weight']);
                  $provider = new MemcachedCache();
                  $provider->setMemcached($memcached);
                  break;
              case 'Redis':
                  $redis = new Redis;
                  $redis->connect($config['host'], $config['port'], $config['timeout']);
                  $provider = new RedisCache;
                  $provider->setRedis($redis);
                  break;
              default:
                  throw new InvalidArgumentException('Cache driver "' . $config['driver'] . '" is not supported.');
          }
  
          return $this->caches[$name] = new Cache($provider);
      }
code_tokens: public function store ( $ name = null ) { if ( is_null ( $ name ) ) { $ name = $ this -> defaultStore ; } if ( isset ( $ this -> caches [ $ name ] ) ) { return $ this -> caches [ $ name ] ; } $ config = config ( 'cache.stores.' . $ name ) ; if ( $ config === null ) { throw new InvalidArgumentException ( 'Cache store "' . $ name . '" is not defined.' ) ; } if ( ! isset ( $ config [ 'driver' ] ) ) { throw new InvalidArgumentException ( 'Cache driver for store "' . $ name . '" is not specified.' ) ; } switch ( $ config [ 'driver' ] ) { case 'APCu' : $ provider = new ApcuCache ; break ; case 'Array' : $ provider = new ArrayCache ; break ; case 'File' : $ provider = new FilesystemCache ( $ config [ 'path' ] ) ; break ; case 'Memcached' : $ memcached = new Memcached ( ) ; $ memcached -> addServer ( $ config [ 'host' ] , $ config [ 'port' ] , $ config [ 'weight' ] ) ; $ provider = new MemcachedCache ( ) ; $ provider -> setMemcached ( $ memcached ) ; break ; case 'Redis' : $ redis = new Redis ; $ redis -> connect ( $ config [ 'host' ] , $ config [ 'port' ] , $ config [ 'timeout' ] ) ; $ provider = new RedisCache ; $ provider -> setRedis ( $ redis ) ; break ; default : throw new InvalidArgumentException ( 'Cache driver "' . $ config [ 'driver' ] . '" is not supported.' ) ; } return $ this -> caches [ $ name ] = new Cache ( $ provider ) ; }
docstring: Get a Cache instance by given store name.
  
  @param string|null $name
  @return \Core\Services\Contracts\Cache
  @throws \InvalidArgumentException
docstring_tokens: Get a Cache instance by given store name .