Add clear cache command. #3034

Merged
merged 3 commits into from Jul 15, 2014

Conversation

Projects
None yet
9 participants
Contributor

Petah commented Jun 4, 2014

No description provided.

Contributor

Petah commented Jun 4, 2014

Added clear cache command to satisfy #941 (comment)

@stof stof commented on an outdated diff Jun 4, 2014

src/Composer/Command/ClearCacheCommand.php
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * @author David Neilsen <petah.p@gmail.com>
+ */
+class ClearCacheCommand extends Command
+{
+ protected function configure()
+ {
+ $this
+ ->setName('clear-cache')
+ ->setAliases(array('clearcache'))
+ ->setDescription('Clears composer\'s interal package cache.')
@stof

stof Jun 4, 2014

Contributor

typo

huyndx commented Jul 4, 2014

cool

@naderman naderman added a commit that referenced this pull request Jul 15, 2014

@naderman naderman Merge pull request #3034 from Petah/clear-cache
Add clear cache command.
ea6917c

@naderman naderman merged commit ea6917c into composer:master Jul 15, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
Contributor

fprochazka commented Jul 15, 2014

Oh wow! 👏 🍰

Petah deleted the Petah:clear-cache branch Jul 15, 2014

@Seldaek Seldaek commented on the diff Jul 18, 2014

src/Composer/Command/ClearCacheCommand.php
+ ->setAliases(array('clearcache'))
+ ->setDescription('Clears composer\'s internal package cache.')
+ ->setHelp(<<<EOT
+The <info>clear-cache</info> deletes all cached packages from composer's
+cache directory.
+EOT
+ )
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $config = Factory::createConfig();
+ $io = $this->getIO();
+
+ $cachePath = realpath($config->get('cache-repo-dir'));
@Seldaek

Seldaek Jul 18, 2014

Owner

This only clears the repo cache.. and not all caches. It's rather incomplete.

@Petah

Petah Jul 18, 2014

Contributor

Sorry about that, is there any docs on how I can access the other caches?

@Seldaek

Seldaek Jul 18, 2014

Owner

All these config keys should be flushed I guess if you want a comprehensive cache clear:

    'cache-dir' => '{$home}/cache',
    'cache-files-dir' => '{$cache-dir}/files',
    'cache-repo-dir' => '{$cache-dir}/repo',
    'cache-vcs-dir' => '{$cache-dir}/vcs',
@Rican7

Rican7 Jul 29, 2014

Yea, I went to use this new cache clear command and it only partially worked. To really have the cache cleared this will need to clear the other directories too.

Petah referenced this pull request Jul 30, 2014

Merged

Clear all the caches #3175

loostro commented Dec 12, 2014

👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment