Created
March 21, 2017 12:30
-
-
Save nojimage/f4fe034076dd8e614b5295ba8a85bc6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::uses('Shell', 'Console'); | |
/** | |
* ClearCache | |
* | |
* CakePHP 2.0 | |
* PHP versions 5 | |
* | |
* Copyright 2012, nojimage (http://php-tips.com/) | |
* | |
* Licensed under The MIT License | |
* Redistributions of files must retain the above copyright notice. | |
* | |
* @filesource | |
* @version 2.0 | |
* @author nojimage <nojimage at gmail.com> | |
* @copyright 2012 nojimage (http://php-tips.com/) | |
* @license http://www.opensource.org/licenses/mit-license.php The MIT License | |
* @link http://php-tips.com/ | |
* | |
* ===== | |
* Usage: | |
* | |
* in console | |
* | |
* cake Berry.ClearCache | |
* | |
*/ | |
class ClearCacheShell extends Shell { | |
public function main() { | |
$cacheNames = Cache::configured(); | |
foreach ($cacheNames as $name) { | |
$this->out("Clear $name: ", false); | |
if (Cache::clear(false, $name)) { | |
$this->out('<info>SUCCESS</info>'); | |
} else { | |
$this->out('<error>FAIL</error>'); | |
} | |
} | |
} | |
public function getOptionParser() { | |
$parser = parent::getOptionParser(); | |
$parser->description( | |
__d('berry', 'clear cached data.') | |
); | |
return $parser; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment