Skip to content

Instantly share code, notes, and snippets.

@nojimage
Created March 21, 2017 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nojimage/f4fe034076dd8e614b5295ba8a85bc6c to your computer and use it in GitHub Desktop.
Save nojimage/f4fe034076dd8e614b5295ba8a85bc6c to your computer and use it in GitHub Desktop.
<?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