Esempio n. 1
0
 public function testClearAllByNamespace()
 {
     $capabilities = $this->_storage->getCapabilities();
     if (!$capabilities->getClearByNamespace()) {
         $this->setExpectedException('Zend\\Cache\\Exception\\RuntimeException');
         $this->_storage->clearByNamespace(Adapter::MATCH_ALL);
         return;
     }
     $items = array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3');
     $namespaces = array('ns1', 'ns2');
     foreach ($namespaces as $ns) {
         $this->_options->setNamespace($ns);
         foreach ($items as $k => $v) {
             $this->assertTrue($this->_storage->setItem($ns . $k, $ns . $v));
         }
     }
     $clearNs = array_shift($namespaces);
     $this->_options->setNamespace($clearNs);
     $this->assertTrue($this->_storage->clearByNamespace(Adapter::MATCH_ALL));
     // wait
     usleep($capabilities->getTtlPrecision() * 2000000);
     foreach ($items as $k => $v) {
         $this->assertFalse($this->_storage->hasItem($clearNs . $k));
     }
     foreach ($namespaces as $ns) {
         $this->_options->setNamespace($ns);
         foreach ($items as $k => $v) {
             $this->assertTrue($this->_storage->hasItem($ns . $k));
         }
     }
 }