/** * Returns a boolean true/false if the getMulti()-operation for the given * attributes has already been resolves and doesn't need to query any * outside cache/database. * Determining if a find() has not yet been resolved may be useful so that * additional data may be loaded at once. * * @param array $objectIds Ids to getMulti() * @return bool */ public function gotMulti(array $objectIds) { if (!$objectIds) { return true; } $primaryKey = $this->storage->getPrimaryKeyColumns(); $queries = array(); foreach ($objectIds as $id) { $query = array_combine($primaryKey, ObjectManager::makeArray($id)); $query = UUID::convertUUIDs($query, 'alphadecimal'); if (!$this->mapper->get($query)) { $queries[] = $query; } } if ($queries && $this->mapper instanceof Mapper\CachingObjectMapper) { return false; } return $this->foundMulti($queries); }
/** * Query persistent storage for data not found in cache. Note that this * does not use the query options because an individual bucket contents is * based on constructor options, and not query options. Query options merely * change what part of the bucket is returned(or if the query has to fail over * to direct from storage due to being beyond the set of cached values). * * @param array $queries * @return array */ protected function backingStoreFindMulti(array $queries) { // query backing store $options = $this->queryOptions(); $stored = $this->storage->findMulti($queries, $options); $results = array(); // map store results to cache key foreach ($stored as $idx => $rows) { if (!$rows) { // Nothing found, should we cache failures as well as success? continue; } $results[$idx] = $rows; unset($queries[$idx]); } if (count($queries) !== 0) { // Log something about not finding everything? } return $results; }
public function findDescendants(array $queries, array $options = array()) { $data = $this->postRevisionStorage->findMulti($queries, $options); $summary = $this->postSummaryStorage->findMulti($queries, $options); if ($summary) { if ($data) { foreach ($summary as $key => $rows) { if (isset($data[$key])) { $data[$key] += $rows; // Failing to sort is okay, we'd rather display unordered // result than showing an error page with exception krsort($data[$key]); } else { $data[$key] = $rows; } } } else { $data = $summary; } } return $data; }