protected function DrupalCacheArray::set
7.x bootstrap.inc | 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.
1 call to DrupalCacheArray::set()
- DrupalCacheArray::__destruct in drupal-7.x/
includes/ bootstrap.inc - Destructs the DrupalCacheArray object.
1 method overrides DrupalCacheArray::set()
- ThemeRegistry::set in drupal-7.x/
includes/ theme.inc - Writes a value to the persistent cache immediately.
File
- drupal-7.x/
includes/ bootstrap.inc, line 420 - 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);
}
}
}