You are here

protected function DrupalCacheArray::set in Drupal 7

Writes a value to the persistent cache immediately.

Parameters

$data: The data to write to the persistent cache.

$lock: Whether to acquire a lock before writing to cache.

1 call to DrupalCacheArray::set()
DrupalCacheArray::__destruct in includes/bootstrap.inc
Destructs the DrupalCacheArray object.
1 method overrides DrupalCacheArray::set()
ThemeRegistry::set in includes/theme.inc
Writes a value to the persistent cache immediately.

File

includes/bootstrap.inc, line 434
Functions that need to be loaded on every Drupal request.

Class

DrupalCacheArray
Provides a caching wrapper to be used in place of large array structures.

Code

protected function set($data, $lock = TRUE) {

  // Lock cache writes to help avoid stampedes.
  // To implement locking for cache misses, override __construct().
  $lock_name = $this->cid . ':' . $this->bin;
  if (!$lock || lock_acquire($lock_name)) {
    if ($cached = cache_get($this->cid, $this->bin)) {
      $data = $cached->data + $data;
    }
    cache_set($this->cid, $data, $this->bin);
    if ($lock) {
      lock_release($lock_name);
    }
  }
}