function DrupalDatabaseCache::getMultiple in Drupal 7
Implements DrupalCacheInterface::getMultiple().
Overrides DrupalCacheInterface::getMultiple
1 call to DrupalDatabaseCache::getMultiple()
- DrupalDatabaseCache::get in includes/
cache.inc - Implements DrupalCacheInterface::get().
1 method overrides DrupalDatabaseCache::getMultiple()
- DrupalFakeCache::getMultiple in includes/
cache-install.inc - Overrides DrupalDatabaseCache::getMultiple().
File
- includes/
cache.inc, line 347 - Functions and interfaces for cache handling.
Class
- DrupalDatabaseCache
- Defines a default cache implementation.
Code
function getMultiple(&$cids) {
try {
// Garbage collection necessary when enforcing a minimum cache lifetime.
$this
->garbageCollection($this->bin);
// When serving cached pages, the overhead of using db_select() was found
// to add around 30% overhead to the request. Since $this->bin is a
// variable, this means the call to db_query() here uses a concatenated
// string. This is highly discouraged under any other circumstances, and
// is used here only due to the performance overhead we would incur
// otherwise. When serving an uncached page, the overhead of using
// db_select() is a much smaller proportion of the request.
$result = db_query('SELECT cid, data, created, expire, serialized FROM {' . db_escape_table($this->bin) . '} WHERE cid IN (:cids)', array(
':cids' => $cids,
));
$cache = array();
foreach ($result as $item) {
$item = $this
->prepareItem($item);
if ($item) {
$cache[$item->cid] = $item;
}
}
$cids = array_diff($cids, array_keys($cache));
return $cache;
} catch (Exception $e) {
// If the database is never going to be available, cache requests should
// return FALSE in order to allow exception handling to occur.
return array();
}
}