On this page
protected function DrupalCacheArray::set
protected DrupalCacheArray::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
- includes/bootstrap.inc, line 429
- 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);
}
}
}
© 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!bootstrap.inc/function/DrupalCacheArray::set/7.x