cvs: php4 /pear/PEAR/Command Remote.php
| From: | Stig Bakken | Date: | Fri, 27 Dec 2002 19:31:37 +0000 |
| Subject: | cvs: php4 /pear/PEAR/Command Remote.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-7970@lists.php.net to get a copy of this message | ||
ssb Fri Dec 27 14:31:37 2002 EDT
Modified files:
/php4/pear/PEAR/Command Remote.php
Log:
* added "clear-cache" command
Index: php4/pear/PEAR/Command/Remote.php
diff -u php4/pear/PEAR/Command/Remote.php:1.25 php4/pear/PEAR/Command/Remote.php:1.26
--- php4/pear/PEAR/Command/Remote.php:1.25 Tue Dec 3 15:51:36 2002
+++ php4/pear/PEAR/Command/Remote.php Fri Dec 27 14:31:37 2002
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: Remote.php,v 1.25 2002/12/03 20:51:36 dickmann Exp $
+// $Id: Remote.php,v 1.26 2002/12/27 19:31:37 ssb Exp $
require_once 'PEAR/Command/Common.php';
require_once 'PEAR/Common.php';
@@ -88,6 +88,16 @@
server, for example if you download the DB package and the latest stable
version of DB is 1.2, the downloaded file will be DB-1.2.tgz.',
),
+ 'clear-cache' => array(
+ 'summary' => 'Clear XML-RPC Cache',
+ 'function' => 'doClearCache',
+ 'shortcut' => 'cc',
+ 'options' => array(),
+ 'doc' => '
+Clear the XML-RPC cache. See also the cache_ttl configuration
+parameter.
+',
+ ),
);
// }}}
@@ -352,6 +362,43 @@
$this->ui->outputData($data, $command);
}
return true;
+ }
+
+ // }}}
+ // {{{ doClearCache()
+
+ function doClearCache($command, $options, $params)
+ {
+ $cache_dir = $this->config->get('cache_dir');
+ $verbose = $this->config->get('verbose');
+ $output = '';
+ if (!($dp = @opendir($cache_dir))) {
+ return $this->raiseError("opendir($cache_dir) failed: $php_errormsg");
+ }
+ if ($verbose >= 1) {
+ $output .= "reading directory $cache_dir\n";
+ }
+ $num = 0;
+ while ($ent = readdir($dp)) {
+ if (preg_match('/^xmlrpc_cache_[a-z0-9]{32}$/', $ent)) {
+ $path = $cache_dir . DIRECTORY_SEPARATOR . $ent;
+ $ok = @unlink($path);
+ if ($ok) {
+ if ($verbose >= 2) {
+ $output .= "deleted $path\n";
+ }
+ $num++;
+ } elseif ($verbose >= 1) {
+ $output .= "failed to delete $path\n";
+ }
+ }
+ }
+ closedir($dp);
+ if ($verbose >= 1) {
+ $output .= "$num cache entries cleared\n";
+ }
+ $this->ui->outputData(rtrim($output), $command);
+ return $num;
}
// }}}