/**
  * Initialize the internal memcached resource
  *
  * @return MemcachedResource
  */
 protected function getMemcachedResource()
 {
     if (!$this->initialized) {
         $options = $this->getOptions();
         // get resource manager and resource id
         $this->resourceManager = $options->getResourceManager();
         $this->resourceId = $options->getResourceId();
         // init namespace prefix
         $namespace = $options->getNamespace();
         if ($namespace !== '') {
             $this->namespacePrefix = $namespace . $options->getNamespaceSeparator();
         } else {
             $this->namespacePrefix = '';
         }
         // update initialized flag
         $this->initialized = true;
     }
     return $this->resourceManager->getResource($this->resourceId);
 }
 public function testSetLibOptionsOnExistingResource()
 {
     $memcachedInstalled = class_exists('Memcached', false);
     $libOptions = array('compression' => false);
     $resourceId = 'testResourceId';
     $resourceMock = $this->getMock('Memcached', array('setOptions'));
     if (!$memcachedInstalled) {
         $this->setExpectedException('Zend\\Cache\\Exception\\InvalidArgumentException');
     } else {
         $resourceMock->expects($this->once())->method('setOptions')->with($this->isType('array'));
     }
     $this->resourceManager->setResource($resourceId, $resourceMock);
     $this->resourceManager->setLibOptions($resourceId, $libOptions);
 }
Exemplo n.º 3
0
 /**
  * Get memcached resource to share
  *
  * @return MemcachedResource
  * @deprecated Please use the resource manager instead
  */
 public function getMemcachedResource()
 {
     trigger_error('This method is deprecated and will be removed in the feature' . ', please use the resource manager instead', E_USER_DEPRECATED);
     return $this->resourceManager->getResource($this->getResourceId());
 }