Permalink
Browse files

Add cache-files-ttl setting, and docs for the cache

  • Loading branch information...
1 parent b7fb604 commit b05a55488390a81ffc6928a5b6f2254a3f51651e @Seldaek Seldaek committed Nov 11, 2012
Showing with 20 additions and 1 deletion.
  1. +4 −0 doc/04-schema.md
  2. +2 −0 src/Composer/Command/ConfigCommand.php
  3. +10 −0 src/Composer/Config.php
  4. +4 −1 src/Composer/Factory.php
View
@@ -596,6 +596,10 @@ The following options are supported:
* **notify-on-install:** Defaults to `true`. Composer allows repositories to
define a notification URL, so that they get notified whenever a package from
that repository is installed. This option allows you to disable that behaviour.
+* **cache-files-ttl:** Defaults to `15552000` (6 months). Composer caches all
+ dist (zip, tar, ..) packages that it downloads. Those are purged after six
+ months of being unused by default. This option allows you to tweak this
+ duration (in seconds) or disable it completely by setting it to 0.
Example:
@@ -184,6 +184,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
// handle config values
$uniqueConfigValues = array(
'process-timeout' => array('is_numeric', 'intval'),
+ 'cache-ttl' => array('is_numeric', 'intval'),
+ 'cache-files-ttl' => array('is_numeric', 'intval'),
'vendor-dir' => array('is_string', function ($val) { return $val; }),
'bin-dir' => array('is_string', function ($val) { return $val; }),
'notify-on-install' => array(
View
@@ -120,6 +120,16 @@ public function get($key)
return rtrim($this->process(getenv($env) ?: $this->config[$key]), '/\\');
+ case 'cache-ttl':
+ return (int) $this->config[$key];
+
+ case 'cache-files-ttl':
+ if (isset($this->config[$key])) {
+ return (int) $this->config[$key];
+ }
+
+ return (int) $this->config['cache-ttl'];
+
case 'home':
return rtrim($this->process($this->config[$key]), '/\\');
View
@@ -240,7 +240,10 @@ protected function addLocalRepository(RepositoryManager $rm, $vendorDir)
*/
public function createDownloadManager(IOInterface $io, Config $config)
{
- $cache = new Cache($io, $config->get('home').'/cache.files/', 'a-z0-9_./');
+ $cache = null;
+ if ($config->get('cache-files-ttl') > 0) {
+ $cache = new Cache($io, $config->get('home').'/cache.files/', 'a-z0-9_./');
+ }
$dm = new Downloader\DownloadManager();
$dm->setDownloader('git', new Downloader\GitDownloader($io, $config));

0 comments on commit b05a554

Please sign in to comment.