You are here

public function FastCacheItem::clear in Drupal driver for SQL Server and SQL Azure 8

Clear a cache item.

Parameters

string $key: If set, the cache ID or an array of cache IDs. Otherwise, all cache entries that

  • can expire are deleted. The $wildcard argument will be ignored if set to NULL.

bool $wildcard: If TRUE, the $cid argument must contain a string value and cache IDs starting with $cid are deleted in addition to the exact cache ID specified by $cid. If $wildcard is TRUE and $cid is '*', the entire cache is emptied.

File

drivers/lib/Drupal/Driver/Database/sqlsrv/FastCacheItem.php, line 84
fastcacheitem Class.

Class

FastCacheItem

Namespace

Drupal\Driver\Database\sqlsrv

Code

public function clear($key, $wildcard = FALSE) {
  if (!isset($key)) {
    if (empty($this->data)) {
      return;
    }
    else {
      $this->data = array();
    }
  }
  elseif (isset($key) && $wildcard === FALSE) {
    unset($this->data[$key]);
  }
  else {
    if ($key == '*') {

      // Completely reset this binary.
      unset($this->data);
      $this->data = array();
    }
    else {

      // Only reset items that start with $key.
      foreach ($this->data as $k => $v) {
        if ($this
          ->startsWith($k, $key)) {
          unset($this->data[$k]);
        }
      }
    }
  }
  $this->persist = TRUE;
}