Implements Drupal\Core\Cache\CacheBackendInterface::set().
Overrides CacheBackendInterface::set
public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {
try {
$flat_tags = $this
->flattenTags($tags);
$checksum = $this
->checksumTags($flat_tags);
$fields = array(
'serialized' => 0,
'created' => REQUEST_TIME,
'expire' => $expire,
'tags' => implode(' ', $flat_tags),
'checksum_invalidations' => $checksum['invalidations'],
'checksum_deletions' => $checksum['deletions'],
);
if (!is_string($data)) {
$fields['data'] = serialize($data);
$fields['serialized'] = 1;
}
else {
$fields['data'] = $data;
$fields['serialized'] = 0;
}
Database::getConnection()
->merge($this->bin)
->key(array(
'cid' => $cid,
))
->fields($fields)
->execute();
} catch (Exception $e) {
// The database may not be available, so we'll ignore cache_set requests.
}
}