You are here

public function FeedsHTTPCache::clear in Feeds 7.2

Implements DrupalCacheInterface::clear().

Overrides DrupalDatabaseCache::clear

File

includes/FeedsHTTPCache.inc, line 193
Contains FeedsHTTPCache class.

Class

FeedsHTTPCache
Cache implementation for the Feeds HTTP cache.

Code

public function clear($cid = NULL, $wildcard = FALSE) {
  if (empty($cid)) {

    // Clean up expired cached files.
    $cache_lifetime = variable_get('cache_lifetime', 0);

    // Check if expired cached files should be cleaned up now.
    if ($cache_lifetime) {
      $cache_flush = variable_get('cache_flush_' . $this->bin, 0);
      $flush_expired = $cache_flush && REQUEST_TIME > $cache_flush + $cache_lifetime;
    }
    else {
      $flush_expired = TRUE;
    }
    if ($flush_expired) {

      // Clear files for which the cache entries are expired.
      $result = db_select($this->bin)
        ->fields($this->bin, array(
        'cid',
      ))
        ->condition('expire', CACHE_PERMANENT, '<>')
        ->condition('expire', REQUEST_TIME, '<')
        ->execute()
        ->fetchAllAssoc('cid');
      $cids = array_keys($result);
      $this
        ->deleteMultipleFiles($cids);
    }
  }
  else {
    if ($wildcard) {
      if ($cid == '*') {
        $this
          ->deleteAllFiles();
      }
      else {
        $this
          ->deleteFilesStartingWith($cid);
      }
    }
    elseif (is_array($cid)) {
      $this
        ->deleteMultipleFiles($cid);
    }
    else {
      $this
        ->deleteFile($cid);
    }
  }
  parent::clear($cid, $wildcard);
}