Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.8.3

Request #16119 Count cache entries cleaned
Submitted: 2009-04-18 18:46 UTC
From: farell Assigned:
Status: Bogus Package: Cache_Lite (version Irrelevant)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 34 - 29 = ?

 
 [2009-04-18 18:46 UTC] farell (Laurent Laville)
Description: ------------ With current API, we can clear a cache with Cache_Lite::clean and only notified if the clean is OK (true) or KO (false). I appreciate instead of a boolean return value, to get count of files removed. That will allow to application that used Cache_Lite to print something like PEAR did when you run command pear clear-cache reading directory <cache_dir_name> <count> cache entries cleared Expected result: ---------------- return <count> cache entries cleared Actual result: -------------- return true if cache clean and false otherwise

Comments

 [2011-08-27 09:44 UTC] ivonascimento (Ivo Nascimento)
The patch for this are recognized by the form as a lisp file(I do no why), so I add here the patch Index: Lite.php =================================================================== --- Lite.php (revision 315595) +++ Lite.php (working copy) @@ -247,6 +247,13 @@ * @var boolean */ var $_errorHandlingAPIBreak = false; + + /** + * + * represent the number of cleaned cache Itens + * @var int $_cleanItemCount + */ + var $_cleanItemCount = 0; // --- Public methods --- @@ -312,6 +319,27 @@ $this->$property = $value; } } + + /** + * return the informations about the clean process + * @access public + * @return Array + */ + function getCleanInfo() { + //TODO add information about cleaned itens by Directory + return Array( + 'totalItem' => $this->_cleanItemCount + ); + } + + /** + * reset the _cleanItemCount information + * @return void + * @access private + */ + function _resetCleanItemCount() { + $this->_cleanItemCount = 0; + } /** * Test if a cache is available and (if yes) return it @@ -454,7 +482,9 @@ */ function clean($group = false, $mode = 'ingroup') { + $this->_resetCleanItemCount(); return $this->_cleanDir($this->_cacheDir, $group, $mode); + } /** @@ -589,6 +619,7 @@ if (!@unlink($file)) { return $this->raiseError('Cache_Lite : Unable to remove cache !', -3); } + $this->_cleanItemCount++; return true; }
 [2011-08-29 14:48 UTC] tacker (Markus Tacker)
-Status: Open +Status: Bogus -Package Version: 1.7.7 +Package Version: Irrelevant -PHP Version: 5.2.9 +PHP Version: Irrelevant
Sorry, but your problem does not imply a bug in PEAR itself. For a list of more appropriate places to ask for help using PEAR, please visit http://pear.php.net/support/ as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PEAR. Hoi Farell, thanks for taking the time to report this issue. This can easily be achieved by extending the Cache_Lite class with a class which implements the desired functionality. <?php class MyCacheLite extends Cache_Lite { /** * represent the number of cleaned cache Itens * @var int $_cleanItemCount */ private $cleanItemCount = 0; /** * return the informations about the clean process * @return Array * @todo TODO add information about cleaned itens by Directory */ public function getCleanInfo() { return array( 'totalItems' => $this->_cleanItemCount ); } /** * reset the _cleanItemCount information * @return void */ private function resetCleanItemCount() { $this->cleanItemCount = 0; } /** * @see Cache_Lite::clean() */ public function clean($group = null, $mode = null) { $this->resetCleanItemCount(); parent::clean($group, $mode); } /** * @see Cache_Lite::unlink() */ protected function _unlink($file) { $this->cleanItemCount++; parent::_unlink($file); } }