Writes a value to the persistent cache immediately.
$data: The data to write to the persistent cache.
$lock: Whether to acquire a lock before writing to cache.
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, CacheBackendInterface::CACHE_PERMANENT, $this->tags);
if ($lock) {
lock()
->release($lock_name);
}
}
}