1 cache.inc | BackdropDatabaseCache::set($cid, $data, $expire = CACHE_PERMANENT) |
Implements BackdropCacheInterface::set().
Overrides BackdropCacheInterface::set
File
- core/
includes/ cache.inc, line 521 - Functions and interfaces for cache handling.
Class
- BackdropDatabaseCache
- Defines a default cache implementation.
Code
function set($cid, $data, $expire = CACHE_PERMANENT) {
$fields = array(
'serialized' => 0,
'created' => REQUEST_TIME,
'expire' => $expire,
);
if (!is_string($data)) {
$fields['data'] = serialize($data);
$fields['serialized'] = 1;
}
else {
$fields['data'] = $data;
$fields['serialized'] = 0;
}
try {
db_merge($this->bin)
->key(array('cid' => $cid))
->fields($fields)
->execute();
}
catch (Exception $e) {
// The database may not be available, so we'll ignore these calls.
}
}