function drush_directory_cache

8.0.x drush_directory_cache($subdir = '')
6.x drush_directory_cache($subdir = '')
7.x drush_directory_cache($subdir = '')
4.x drush_directory_cache()
5.x drush_directory_cache($subdir = '')
master drush_directory_cache($subdir = '')

The path to the global cache directory.


subdir: Return the specified subdirectory inside the global cache directory instead. The subdirectory is created.

5 calls to drush_directory_cache()
DrushFileCache::cacheDirectory in includes/
drush_download_file in includes/
Download a file using wget, curl or file_get_contents, or via download cache.
make_download_git in commands/make/
Checks out a git repository to the specified download location.
package_handler_download_project in commands/pm/package_handler/
Download a project.
_drush_usage_get_file in commands/core/


includes/, line 810
Functions used by drush to query the environment and setting the current configuration.


function drush_directory_cache($subdir = '') {
  $cache_locations = array();
  if (getenv('CACHE_PREFIX')) {
    $cache_locations[getenv('CACHE_PREFIX')] = 'cache';
  $home = drush_server_home();
  if ($home) {
    $cache_locations[$home] = '.drush/cache';
  $cache_locations[drush_find_tmp()] = 'drush-' . drush_get_username() . '/cache';
  foreach ($cache_locations as $base => $dir) {
    if (!empty($base) && is_writable($base)) {
      $cache_dir = $base . '/' . $dir;
      if (!empty($subdir)) {
        $cache_dir .= '/' . $subdir;
      if (drush_mkdir($cache_dir)) {
        return $cache_dir;
      else {
        // If the base directory is writable, but the cache directory
        // is not, then we will get an error. The error will be displayed,
        // but we will still call drush_clear_error so that we can go
        // on and try the next location to see if we can find a cache
        // directory somewhere.
  return drush_set_error('DRUSH_NO_WRITABLE_CACHE', dt('Drush must have a writable cache directory; please insure that one of the following locations is writable: @locations', array('@locations' => implode(',', array_keys($cache_locations)))));