Thursday 30 April 2015

How to delete the Zend Cache files from server


How to delete the zend cache files from server


How to create an object of Zend Cache
$cache = Zend_Cache::factory(
                        'Core', 'File', array(
                    'lifetime' => 3600 * 24 * 7, //cache is cleaned once a day                            
                    'automatic_serialization' => true
                        ), array('cache_dir' => APPLICATION_PATH . '/cache')
        );


Remove the cache by cache-id In this only one cache file will be removed from server.
$cache->remove('idToRemove');


Remove All cache files from Server. (When we delete files, caching automatic clear because we are using cache in files)
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);


Remove all outdated caching files.
$cache->clean(Zend_Cache::CLEANING_MODE_OLD);


Remove the cahe files which have two tags.
$cache->clean(
    Zend_Cache::CLEANING_MODE_MATCHING_TAG,
    array('matchingTag1', 'matchingTag2','matchingTag3') //Will remove which have matchingTag1 and matchingTag2 and matchingTag3
);


Remove all files which have not tag assign few tags.
$cache->clean(
    Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG,
    array('NotmatchingTag1', 'NotmatchingTag2') //Will Remove all the cahce which are NOT tagged with NotmatchingTag1 OR NotmatchingTag2
);


Remove all the cache files which have any tag (any of two or three).
$cache->clean(
    Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, //Will remove which have matchingTag1 OR matchingTag2 OR matchingTag3
     array('matchingTag1', 'matchingTag2','matchingTag3')
);