You are here

public function ChainedStorage::has in Supercache 8

Same name and namespace in other branches
  1. 2.0.x src/KeyValueStore/ChainedStorage.php \Drupal\supercache\KeyValueStore\ChainedStorage::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 DatabaseStorage::has

File

src/KeyValueStore/ChainedStorage.php, line 63
Contains \Drupal\supercache\KeyValueStore\ChainedStorage;

Class

ChainedStorage
Defines a chained key value storage that uses any cache backend on top of the database default key/value storage.

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);
}