當前位置: 首頁>>代碼示例>>PHP>>正文


PHP StorageInterface::clearByNamespace方法代碼示例

本文整理匯總了PHP中Zend\Cache\Storage\StorageInterface::clearByNamespace方法的典型用法代碼示例。如果您正苦於以下問題:PHP StorageInterface::clearByNamespace方法的具體用法?PHP StorageInterface::clearByNamespace怎麽用?PHP StorageInterface::clearByNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Cache\Storage\StorageInterface的用法示例。


在下文中一共展示了StorageInterface::clearByNamespace方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testClearByNamespace

 public function testClearByNamespace()
 {
     if (!$this->_storage instanceof ClearByNamespaceInterface) {
         $this->markTestSkipped("Storage doesn't implement ClearByNamespaceInterface");
     }
     // write 2 items of 2 different namespaces
     $this->_options->setNamespace('ns1');
     $this->assertTrue($this->_storage->setItem('key1', 'value1'));
     $this->_options->setNamespace('ns2');
     $this->assertTrue($this->_storage->setItem('key2', 'value2'));
     // clear unknown namespace should return true but clear nothing
     $this->assertTrue($this->_storage->clearByNamespace('unknown'));
     $this->_options->setNamespace('ns1');
     $this->assertTrue($this->_storage->hasItem('key1'));
     $this->_options->setNamespace('ns2');
     $this->assertTrue($this->_storage->hasItem('key2'));
     // clear "ns1"
     $this->assertTrue($this->_storage->clearByNamespace('ns1'));
     $this->_options->setNamespace('ns1');
     $this->assertFalse($this->_storage->hasItem('key1'));
     $this->_options->setNamespace('ns2');
     $this->assertTrue($this->_storage->hasItem('key2'));
     // clear "ns2"
     $this->assertTrue($this->_storage->clearByNamespace('ns2'));
     $this->_options->setNamespace('ns1');
     $this->assertFalse($this->_storage->hasItem('key1'));
     $this->_options->setNamespace('ns2');
     $this->assertFalse($this->_storage->hasItem('key2'));
 }
開發者ID:ninahuanca,項目名稱:zf2,代碼行數:29,代碼來源:CommonAdapterTest.php

示例2: testClearByNamespaceThrowsInvalidArgumentExceptionOnEmptyNamespace

 public function testClearByNamespaceThrowsInvalidArgumentExceptionOnEmptyNamespace()
 {
     if (!$this->_storage instanceof ClearByNamespaceInterface) {
         $this->markTestSkipped("Storage doesn't implement ClearByNamespaceInterface");
     }
     $this->setExpectedException('Zend\\Cache\\Exception\\InvalidArgumentException');
     $this->_storage->clearByNamespace('');
 }
開發者ID:razvansividra,項目名稱:pnlzf2-1,代碼行數:8,代碼來源:CommonAdapterTest.php

示例3: __destruct

 /**
  * Object destructor
  *
  * Clean up cache storage
  */
 public function __destruct()
 {
     if ($this->cache !== null) {
         if ($this->cache instanceof ClearByNamespaceCacheStorage) {
             $this->cache->clearByNamespace($this->cache->getOptions()->getNamespace());
         } elseif ($this->cache instanceof FlushableCacheStorage) {
             $this->cache->flush();
         }
     }
 }
開發者ID:eltonoliveira,項目名稱:jenkins,代碼行數:15,代碼來源:MemoryManager.php

示例4: clear

 /**
  * Deletes all items in the pool.
  *
  * @return bool
  *   True if the pool was successfully cleared. False if there was an error.
  */
 public function clear()
 {
     $cleared = false;
     try {
         /* @todo Not at all sure about this... do we really want to flush()? What happens if the storage supports
            /*       namespaces, but none has been provided? */
         $options = $this->storage->getOptions();
         $namespace = $options->getNamespace();
         if ($this->storage instanceof ClearByNamespaceInterface && $namespace) {
             $cleared = $this->storage->clearByNamespace($namespace);
         } elseif ($this->storage instanceof FlushableInterface) {
             $cleared = $this->storage->flush();
         } else {
             throw new CacheException(sprintf("Storage %s does not support clear()", get_class($this->storage)));
         }
     } catch (Exception\InvalidArgumentException $e) {
         throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
     } catch (Exception\ExceptionInterface $e) {
         throw new CacheException($e->getMessage(), $e->getCode(), $e);
     }
     return $cleared;
 }
開發者ID:Nyholm,項目名稱:zend-cache-psr6,代碼行數:28,代碼來源:CacheItemPoolAdapter.php


注:本文中的Zend\Cache\Storage\StorageInterface::clearByNamespace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。