Skip to content

Commit

Permalink
Add warnings if cache engine is ApcEngine or WincacheEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
chris48s committed May 27, 2016
1 parent 6d8d7a7 commit 087c614
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/Shell/CacheShell.php
Expand Up @@ -72,12 +72,20 @@ public function getOptionParser()
public function clear($prefix = null)
{
try {
$engine = Cache::engine($prefix);
Cache::clear(false, $prefix);
if ($engine instanceof \Cake\Cache\Engine\ApcEngine) {
$this->warn("ApcEngine detected: Cleared $prefix CLI cache successfully " .
"but $prefix web cache must be cleared separately.");
} elseif ($engine instanceof \Cake\Cache\Engine\WincacheEngine) {
$this->warn("WincacheEngine detected: Cleared $prefix CLI cache successfully " .
"but $prefix web cache must be cleared separately.");
} else {
$this->out("<success>Cleared $prefix cache</success>");
}
} catch (\InvalidArgumentException $e) {
$this->abort($e->getMessage());
}

$this->out("<success>Cleared $prefix cache</success>");
}

/**
Expand All @@ -87,14 +95,9 @@ public function clear($prefix = null)
*/
public function clearAll()
{
if (version_compare(Configure::version(), '3.2.0', '>=')) {
Cache::clearAll(false);
$this->out("<success>Cleared all caches</success>");
} else {
$prefixes = Cache::configured();
foreach ($prefixes as $prefix) {
$this->clear($prefix);
}
$prefixes = Cache::configured();
foreach ($prefixes as $prefix) {
$this->clear($prefix);
}
}

Expand Down

0 comments on commit 087c614

Please sign in to comment.