You are here

function _brightcove_delete_cache_files in Brightcove Video Connect 7.7

Same name and namespace in other branches
  1. 7.3 brightcove.module \_brightcove_delete_cache_files()
  2. 7.4 brightcove.module \_brightcove_delete_cache_files()
  3. 7.5 brightcove.module \_brightcove_delete_cache_files()
  4. 7.6 brightcove.module \_brightcove_delete_cache_files()

Helper function to be able to delete unnecessary cache files.

Parameters

null $cid:

1 call to _brightcove_delete_cache_files()
brightcove_invalidate_cache in ./brightcove.module
Invalidate outdated cache records.

File

./brightcove.module, line 3227
Brightcove module is an integration layer between any modules using Brightcove API. It makes all necessary checks for the API and makes settings available to the user.

Code

function _brightcove_delete_cache_files($cid = NULL) {
  $cache_settings = variable_get('brightcove_cache_file', []);
  $path = isset($cache_settings['path']) ? _brightcove_cache_fix_file_path($cache_settings['path']) : BRIGHTCOVE_CACHE_FILE_PATH;
  if ($cid) {
    $ext = isset($cache_settings['ext']) ? $cache_settings['ext'] : BRIGHTCOVE_CACHE_FILE_EXT;

    // Delete affected cache file.
    $file = $path . md5($cid) . '.' . $ext;
    unlink($file);
  }
  else {

    // If no cache id given, the module deletes all the cache files from the cache folder.
    $files = glob($path . '*');
    foreach ($files as $file) {
      if (is_file($file)) {
        unlink($file);
      }
    }
  }
}