PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Cleaning the Cache

To remove or invalidate in particular cache id, you can use the remove() method :

<?php
$cache
->remove('idToRemove');

To remove or invalidate several cache ids in one operation, you can use the clean() method. For example to remove all cache records :

<?php
// clean all records
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);

// clean only outdated
$cache->clean(Zend_Cache::CLEANING_MODE_OLD);

If you want to remove cache entries matching the tags 'tagA' and 'tagC':

<?php
$cache
->clean(
    
Zend_Cache::CLEANING_MODE_MATCHING_TAG,
    array(
'tagA''tagC')
);

If you want to remove cache entries not matching the tags 'tagA' or 'tagC':

<?php
$cache
->clean(
    
Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG,
    array(
'tagA''tagC')
);

If you want to remove cache entries matching the tags 'tagA' or 'tagC':

<?php
$cache
->clean(
    
Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG,
    array(
'tagA''tagC')
);

Available cleaning modes are: CLEANING_MODE_ALL, CLEANING_MODE_OLD, CLEANING_MODE_MATCHING_TAG, CLEANING_MODE_NOT_MATCHING_TAG and CLEANING_MODE_MATCHING_ANY_TAG. The latter are, as their names suggest, combined with an array of tags in cleaning operations.

Zend Framework