/** * Clean some cache records * * Available modes are : * 'all' (default) => remove all cache entries ($tags is not used) * 'old' => runs _collectGarbage() * 'matchingTag' => supported * 'notMatchingTag' => supported * 'matchingAnyTag' => supported * * @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()) { if ($tags && !is_array($tags)) { $tags = array($tags); } try { if ($mode == Zend_Cache::CLEANING_MODE_ALL) { return $this->_redis->flushDb(); } if ($mode == Zend_Cache::CLEANING_MODE_OLD) { $this->_collectGarbage(); return TRUE; } if (!count($tags)) { return TRUE; } switch ($mode) { case Zend_Cache::CLEANING_MODE_MATCHING_TAG: $this->_removeByMatchingTags($tags); break; case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: $this->_removeByNotMatchingTags($tags); break; case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: $this->_removeByMatchingAnyTags($tags); break; default: Zend_Cache::throwException('Invalid mode for clean() method: ' . $mode); } } catch (CredisException $e) { Zend_Cache::throwException('Error cleaning cache by mode ' . $mode . ': ' . $e->getMessage(), $e); } return TRUE; }
/** * Clean some cache records * * Available modes are : * 'all' (default) => remove all cache entries ($tags is not used) * 'old' => runs _collectGarbage() * 'matchingTag' => supported * 'notMatchingTag' => supported * 'matchingAnyTag' => supported * * @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()) { if ($tags && !is_array($tags)) { $tags = array($tags); } if ($mode == Zend_Cache::CLEANING_MODE_ALL) { return $this->_redis->flushDb(); } if ($mode == Zend_Cache::CLEANING_MODE_OLD) { $this->_collectGarbage(); return TRUE; } if (!count($tags)) { return TRUE; } $result = TRUE; switch ($mode) { case Zend_Cache::CLEANING_MODE_MATCHING_TAG: $this->_removeByMatchingTags($tags); break; case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: $this->_removeByNotMatchingTags($tags); break; case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: $this->_removeByMatchingAnyTags($tags); break; default: Zend_Cache::throwException('Invalid mode for clean() method: ' . $mode); } return (bool) $result; }
public function testFlush() { $this->credis->set('foo', 'FOO'); $this->assertTrue($this->credis->flushDb()); $this->assertFalse($this->credis->get('foo')); }