Пример #1
0
    public function testClearAll()
    {
        $capabilities = $this->_storage->getCapabilities();
        if (!$capabilities->getClearAllNamespaces()) {
            $this->setExpectedException('Zend\Cache\Exception\ExceptionInterface');
            $this->_storage->clear(AdapterInterface::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));
            }
        }

        $this->assertTrue($this->_storage->clear(AdapterInterface::MATCH_ALL));

        // wait
        usleep($capabilities->getTtlPrecision() * 2000000);

        foreach ($namespaces as $ns) {
            $this->_options->setNamespace($ns);
            foreach ($items as $k => $v) {
                $this->assertFalse($this->_storage->hasItem($ns.$k));
            }
        }
    }
Пример #2
0
 /**
  * Clears all set cache data
  *
  * @param string $tag Tag to clear when the default tag name is not used
  * @return void
  */
 public static function clearCache($tag = null)
 {
     if (self::$_cacheTags) {
         if ($tag == null) {
             $tag = 'Zend_Translator';
         }
         self::$_cache->clear(CacheAdapter::MATCH_TAGS_OR, array('tags' => array($tag)));
     } else {
         self::$_cache->clear(CacheAdapter::MATCH_ALL);
     }
 }
Пример #3
0
 /**
  * Clears all set cache data
  *
  * @param string $tag Tag to clear when the default tag name is not used (Optional)
  * @return void
  */
 public static function clearCache($tag = null)
 {
     if (!self::$_cache instanceof CacheAdapter) {
         return;
     }
     if (self::$_cacheTags) {
         if ($tag == null) {
             $tag = 'Zend_Locale';
         }
         self::$_cache->clear(CacheAdapter::MATCH_TAGS_OR, array('tags' => array($tag)));
     } else {
         self::$_cache->clear(CacheAdapter::MATCH_ALL);
     }
 }
Пример #4
0
 public function tearDown()
 {
     if ($this->cache) {
         $this->cache->clear(CacheAdapter::MATCH_ALL);
     }
 }