| Newsgroups |
php.pear.bugs |
| Message-ID |
<[email protected]> |
Edit report at http://pear.php.net/bugs/bug.php?id=16119&edit=1
ID: 16119
Comment by: [email protected]
Reported By: pear at laurent-laville dot org
Summary: Count cache entries cleaned
Status: Open
Type: Feature/Change Request
Package: Cache_Lite
Package Version: 1.7.7
PHP Version: 5.2.9
Roadmap Versions:
New Comment:
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;
}
Previous Comments:
------------------------------------------------------------------------
[2009-04-18 14:46:57] farell
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
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=16119&edit=1