public function ThemeRegistry::set

public ThemeRegistry::set($data, $lock = TRUE)

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.

Overrides DrupalCacheArray::set

File

includes/theme.inc, line 447
The theme system, which controls the output of Drupal.

Class

ThemeRegistry
Builds the run-time theme registry.

Code

public function set($data, $lock = TRUE) {
  $lock_name = $this->cid . ':' . $this->bin;
  if (!$lock || lock_acquire($lock_name)) {
    if ($cached = cache_get($this->cid, $this->bin)) {
      // Use array merge instead of union so that filled in values in $data
      // overwrite empty values in the current cache.
      $data = array_merge($cached->data, $data);
    }
    else {
      $registry = $this->initializeRegistry();
      $data = array_merge($registry, $data);
    }
    cache_set($this->cid, $data, $this->bin);
    if ($lock) {
      lock_release($lock_name);
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!theme.inc/function/ThemeRegistry::set/7.x