You are here

public function ChainedStorageExpirable::has in Supercache 2.0.x

Same name and namespace in other branches
  1. 8 src/KeyValueStore/ChainedStorageExpirable.php \Drupal\supercache\KeyValueStore\ChainedStorageExpirable::has()

Returns whether a given key exists in the store.

Parameters

string $key: The key to check.

Return value

bool TRUE if the key exists, FALSE otherwise.

Overrides DatabaseStorageExpirable::has

File

src/KeyValueStore/ChainedStorageExpirable.php, line 60
Contains \Drupal\supercache\KeyValueStore\ChainedStorageExpirable.

Class

ChainedStorageExpirable
Defines a default key/value store implementation for expiring items.

Namespace

Drupal\supercache\KeyValueStore

Code

public function has($key) {
  if ($cache = $this->cache
    ->get($key)) {
    if (!empty($this
      ->CacheToKeyValue([
      $cache,
    ]))) {
      return TRUE;
    }
  }

  // The fact that it does not exist in the cache
  // does not mean it does not exist in the database.
  return parent::has($key);
}