You are here

public function fastcacheitem::clear in Drupal driver for SQL Server and SQL Azure 7.3

Same name and namespace in other branches
  1. 7.2 sqlsrv/fastcacheitem.inc \fastcacheitem::clear()

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

sqlsrv/fastcacheitem.inc, line 81
fastcacheitem Class.

Class

fastcacheitem
@file fastcacheitem Class.

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