public function ThemeRegistry::set

7.x theme.inc 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

1 call to ThemeRegistry::set()
ThemeRegistry::__construct in drupal-7.x/includes/theme.inc
Constructs a DrupalCacheArray object.

File

drupal-7.x/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);
    }
  }
}