You are here

function advagg_load_files_info_into_static_cache in Advanced CSS/JS Aggregation 7.2

Load cache bin file info in static cache.


  'filesize' => filesize($filename),
  'mtime' => @filemtime($filename),
  'filename_hash' => $filename_hash,
  'content_hash' => drupal_hash_base64($file_contents),
  'linecount' => $linecount,
  'data' => $filename,
  'fileext' => $ext,

Parameters

array $files: Array; array of filenames.

Return value

array $cached_data. key is $cache_id; value is an array which contains

3 calls to advagg_load_files_info_into_static_cache()
advagg_get_css_aggregate_contents in ./advagg.missing.inc
Given a list of files, grab their contents and glue it into one big string.
advagg_get_info_on_files in ./advagg.inc
Given a filename calculate various hashes and gather meta data.
advagg_get_js_aggregate_contents in ./advagg.missing.inc
Given a list of files, grab their contents and glue it into one big string.

File

./advagg.inc, line 543
Advanced CSS/JS aggregation module.

Code

function &advagg_load_files_info_into_static_cache(array $files) {

  // Get the static cache of this data.
  $cached_data =& drupal_static('advagg_get_info_on_file');

  // Get the statically cached data for all the given files.
  $cache_ids = array();
  foreach ($files as $file) {
    $cache_id = 'advagg:file:' . advagg_drupal_hash_base64($file);
    if (!empty($cached_data) && !empty($cached_data[$cache_id])) {

      // Make sure the cache_id is included.
      $cached_data[$cache_id]['cache_id'] = $cache_id;
    }
    else {
      $cache_ids[$file] = $cache_id;
    }
  }

  // Get info from the cache back-end next.
  if (!empty($cache_ids)) {
    $values = array_values($cache_ids);
    $cache_hits = cache_get_multiple($values, 'cache_advagg_info');
    if (!empty($cache_hits)) {
      foreach ($cache_hits as $hit) {
        if (!empty($hit->data['data'])) {

          // Make sure the cache_id is included.
          $hit->data['cache_id'] = $hit->cid;

          // Add to static cache.
          $cached_data[$hit->cid] = $hit->data;
        }
      }
    }
  }
  return $cached_data;
}