Skip to content

Commit

Permalink
Add cache-files-ttl setting, and docs for the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Nov 11, 2012
1 parent b7fb604 commit b05a554
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions doc/04-schema.md
Expand Up @@ -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:

Expand Down
2 changes: 2 additions & 0 deletions src/Composer/Command/ConfigCommand.php
Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions src/Composer/Config.php
Expand Up @@ -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]), '/\\');

Expand Down
5 changes: 4 additions & 1 deletion src/Composer/Factory.php
Expand Up @@ -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));
Expand Down

0 comments on commit b05a554

Please sign in to comment.