Exemplo n.º 1
0
 /**
  * Initializes the Memcache Module
  */
 private function initializeMemCached()
 {
     $this->memcached = new \Memcached();
     // support multiple hosts using semicolon to separate hosts
     $hosts = explode(';', $this->host);
     // different ports for each hosts the same way
     $ports = explode(';', $this->port);
     if (count($ports) < 1) {
         $ports = array_fill(0, count($hosts), self::DEFAULT_PORT);
     } elseif (count($ports) === 1) {
         // if we have just one port, use it for all hosts
         $usedPort = $ports[0];
         $ports = array_fill(0, count($hosts), $usedPort);
     }
     foreach ($hosts as $i => $host) {
         if (!isset($ports[$i])) {
             /*
              * if we have a difference between the count of hosts and
              * the count of ports, use the default port to fill the gap
              */
             $ports[$i] = self::DEFAULT_PORT;
         }
         $this->memcached->addServer($host, $ports[$i]);
     }
 }
Exemplo n.º 2
0
 /**
  * Store an item.
  */
 public function testSetExpiration()
 {
     self::assertSame($this->object, $this->object->setExpiration('test'));
 }