You are here

public function APDQCache::isEmpty in Asynchronous Prefetch Database Query Cache 7

Implements DrupalCacheInterface::isEmpty().

Overrides DrupalDatabaseCache::isEmpty

File

./apdqc.cache.inc, line 800
Extends Drupal's default database cache so async queries happen.

Class

APDQCache
A pretty darn quick cache implementation of Drupal's default cache backend.

Code

public function isEmpty() {
  $this
    ->garbageCollection();
  $real_table_name = Database::getConnection()
    ->prefixTables("{" . db_escape_table($this->bin) . "}");
  $result = apdqc_query(array(
    $this->bin,
  ), array(), "SELECT TRUE FROM {$real_table_name} LIMIT 1");
  if (is_string($result) && $result === 'NO DB') {
    return parent::isEmpty();
  }
  if (!empty($result) && $result instanceof mysqli_result) {
    $empty_table = $result
      ->fetch_row();
  }
  if (empty($result) || empty($empty_table)) {
    return TRUE;
  }
  return FALSE;
}