1 bootstrap.inc protected BackdropCacheArray::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.

File

core/includes/bootstrap.inc, line 448
Functions that need to be loaded on every Backdrop request.

Class

BackdropCacheArray
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($this->bin)->get($this->cid)) {
      $data = $cached->data + $data;
    }
    cache($this->bin)->set($this->cid, $data);
    if ($lock) {
      lock_release($lock_name);
    }
  }
}