/**
  * @param string $id Key name
  * @return MemcacheKey
  */
 public function get($id)
 {
     if (!$this->has($id) || !$this->memcacheCollection[$id] instanceof MemcacheKey) {
         throw MemcacheCollectionException::invalidKey($id);
     }
     return $this->memcacheCollection[$id];
 }
 public function get($id)
 {
     if (!$this->has($id) || !$this->collection[$id] instanceof MemcacheNamespace) {
         throw MemcacheCollectionException::invalidNamespace($id);
     }
     return $this->collection[$id];
 }
 private function _prepareMemcacheKeyCollection()
 {
     foreach ($this->configMemcacheKeys as $key => $configuration) {
         if ($this->keyCollection->has($key)) {
             throw MemcacheCollectionException::duplicateMemcacheKey($key);
         }
         if (!$this->_hasConfiguration('pattern', $configuration)) {
             throw MemcacheCollectionException::missingRequiredMemcacheKeyConfig($key, 'pattern');
         }
         $memcacheKey = new MemcacheKey();
         $memcacheKey->setPattern($configuration['pattern']);
         $namespaces = $this->_getConfiguration('namespaces', $configuration, array());
         foreach ($namespaces as $eachNamespace) {
             if (!$this->namespaceCollection->has($eachNamespace)) {
                 throw new MemcacheCollectionException("Invalid namespace {$eachNamespace} for memcache key {$key}");
             }
             $memcacheKey->addNamespace($this->namespaceCollection->get($eachNamespace));
         }
         // compile pattern regexpression to setup pattern variables
         $variables = $this->_setupMemcacheKeyVariables($memcacheKey->getPattern());
         $memcacheKey->setVariables($variables);
         // add to collection
         $this->keyCollection->set($key, $memcacheKey);
     }
 }