function DrupalDatabaseCache::set in Drupal 7
Implements DrupalCacheInterface::set().
Overrides DrupalCacheInterface::set
1 method overrides DrupalDatabaseCache::set()
- DrupalFakeCache::set in includes/
cache-install.inc - Overrides DrupalDatabaseCache::set().
File
- includes/
cache.inc, line 458 - Functions and interfaces for cache handling.
Class
- DrupalDatabaseCache
- 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 cache_set requests.
}
}