You are here

public function FeedsHTTPCache::isEmpty in Feeds 7.2

Implements DrupalCacheInterface::isEmpty().

Overrides DrupalDatabaseCache::isEmpty

File

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

Class

FeedsHTTPCache
Cache implementation for the Feeds HTTP cache.

Code

public function isEmpty() {

  // Check database first.
  if (!parent::isEmpty()) {
    return FALSE;
  }

  // Check if the cache directory is empty.
  $file_cache_dir = $this
    ->getCacheDir();
  if (is_dir($file_cache_dir)) {
    $dir = dir($file_cache_dir);
    while (($entry = $dir
      ->read()) !== FALSE) {
      if ($entry == '.' || $entry == '..') {
        continue;
      }

      // At least one file is found, so the cache directory is not empty.
      $dir
        ->close();
      return FALSE;
    }

    // No files found. The cache directory is empty.
    $dir
      ->close();
    return TRUE;
  }

  // No cache dir found.
  return TRUE;
}