diff --git a/src/Commands/Env/ClearCacheCommand.php b/src/Commands/Env/ClearCacheCommand.php index 292656d1c..ab5e824e5 100644 --- a/src/Commands/Env/ClearCacheCommand.php +++ b/src/Commands/Env/ClearCacheCommand.php @@ -27,18 +27,21 @@ class ClearCacheCommand extends TerminusCommand implements SiteAwareInterface * @aliases env:cc * * @param string $site_env Site & environment in the format `site-name.env` + * @param array $options + * @option bool $framework_cache [true|false] Clear the CMS cache + * @option bool $varnish_cache [true|false] Clear the edge cache * * @usage . Clears caches for 's environment. * * @throws \Pantheon\Terminus\Exceptions\TerminusProcessException * @throws \Pantheon\Terminus\Exceptions\TerminusException */ - public function clearCache($site_env) + public function clearCache($site_env, $options = ['framework_cache' => true, 'varnish_cache' => false,]) { $this->requireSiteIsNotFrozen($site_env); $env = $this->getEnv($site_env); - $this->processWorkflow($env->clearCache()); + $this->processWorkflow($env->clearCache($options)); $this->log()->notice( 'Caches cleared on {env}.', ['env' => $env->getName()] diff --git a/src/Commands/Redis/ClearCommand.php b/src/Commands/Redis/ClearCommand.php new file mode 100644 index 000000000..fa2a4a16c --- /dev/null +++ b/src/Commands/Redis/ClearCommand.php @@ -0,0 +1,44 @@ + Clear the Redis cache for . + * + * @throws \Pantheon\Terminus\Exceptions\TerminusProcessException + * @throws \Pantheon\Terminus\Exceptions\TerminusException + */ + public function clear($site_env) + { + $this->requireSiteIsNotFrozen($site_env); + $site = $this->getSite(); + $env = $this->getEnv($site_env); + + $workflow = $site->getRedis()->clear($env); + $this->processWorkflow($workflow); + $this->log()->notice($workflow->getMessage()); + } +} diff --git a/src/Models/Environment.php b/src/Models/Environment.php index f2fa4885f..a47816eaa 100755 --- a/src/Models/Environment.php +++ b/src/Models/Environment.php @@ -110,9 +110,9 @@ public function changeConnectionMode($mode) * * @return Workflow */ - public function clearCache() + public function clearCache(array $options = []) { - return $this->getWorkflows()->create('clear_cache', ['params' => ['framework_cache' => true,],]); + return $this->getWorkflows()->create('clear_cache', ['params' => $options,]); } /** diff --git a/src/Models/Redis.php b/src/Models/Redis.php index 8a0e308b3..103c2be99 100755 --- a/src/Models/Redis.php +++ b/src/Models/Redis.php @@ -16,7 +16,7 @@ class Redis extends AddOnModel * @param Environment $env An object representing the environment on which to clear the Redis cache * @return Workflow */ - public function clear($env) + public function clear(Environment $env) { // @Todo: Change this when the env model conversion is merged return $env->getWorkflows()->create('clear_redis_cache');