コード例 #1
0
ファイル: TwoLevels.php プロジェクト: netvlies/zf
 /**
  * Clean some cache records
  *
  * Available modes are :
  * Zend_Cache::CLEANING_MODE_ALL (default)    => remove all cache entries ($tags is not used)
  * Zend_Cache::CLEANING_MODE_OLD              => remove too old cache entries ($tags is not used)
  * Zend_Cache::CLEANING_MODE_MATCHING_TAG     => remove cache entries matching all given tags
  *                                               ($tags can be an array of strings or a single string)
  * Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags}
  *                                               ($tags can be an array of strings or a single string)
  * Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags
  *                                               ($tags can be an array of strings or a single string)
  *
  * @param  string $mode Clean mode
  * @param  array  $tags Array of tags
  * @throws Zend_Cache_Exception
  * @return boolean true if no problem
  */
 public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
 {
     switch ($mode) {
         case Zend_Cache::CLEANING_MODE_ALL:
             $boolFast = $this->_fastBackend->clean(Zend_Cache::CLEANING_MODE_ALL);
             $boolSlow = $this->_slowBackend->clean(Zend_Cache::CLEANING_MODE_ALL);
             return $boolFast && $boolSlow;
             break;
         case Zend_Cache::CLEANING_MODE_OLD:
             return $this->_slowBackend->clean(Zend_Cache::CLEANING_MODE_OLD);
         case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
             $ids = $this->_slowBackend->getIdsMatchingTags($tags);
             $res = true;
             foreach ($ids as $id) {
                 $bool = $this->remove($id);
                 $res = $res && $bool;
             }
             return $res;
             break;
         case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
             $ids = $this->_slowBackend->getIdsNotMatchingTags($tags);
             $res = true;
             foreach ($ids as $id) {
                 $bool = $this->remove($id);
                 $res = $res && $bool;
             }
             return $res;
             break;
         case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
             $ids = $this->_slowBackend->getIdsMatchingAnyTags($tags);
             $res = true;
             foreach ($ids as $id) {
                 $bool = $this->remove($id);
                 $res = $res && $bool;
             }
             return $res;
             break;
         default:
             Zend_Cache::throwException('Invalid mode for clean() method');
             break;
     }
 }
コード例 #2
0
 /**
  * Clear all the cache values.
  * @return CacheableInterface
  */
 public function clear()
 {
     $this->cache->clean(\Zend_Cache::CLEANING_MODE_ALL);
     return $this;
 }