/** * Reads an array of cache objects from storage. * * @param string $keys - Ids of the cache entry to read * @return array of vB_CacheObjects */ protected function readCacheArray($keys) { $cacheids = array(); foreach($keys as $id => $key) { $cacheids[$id] = "'" . vB::$db->escape_string($key) . "'"; } $rst = vB::$db->query_read_slave(" SELECT cacheid, data, expires, locktime, serialized FROM " . TABLE_PREFIX . "cache WHERE cacheid in (" . implode(',' , $cacheids) . ") AND expires > " . TIMENOW ); if (!$rst) { return false; } $found = array(); $missing = array(); while($record = vB::$db->fetch_array($rst)) { if (intval($record['serialized'])) { try { $record['data'] = unserialize($record['data']); if ($record['data']) { $obj = new vB_CacheObject($record['cacheid'], $record['data'], $record['expires'], $record['locktime']); //only return good values if (!$obj->isExpired()) { $found[$record['cacheid']] = $record['data']; } } } catch (exception $e) { //If we got here, something was improperly serialized //There's not much we can do, but we don't want to return bad data. } } else { if (!$obj->isExpired()) { $found[$record['cacheid']] = $record['data']; } } } return $found; }