start of querybyid

This commit is contained in:
Evan Prodromou 2009-04-16 08:44:48 -04:00
parent 573d4cf0fb
commit 3081b2e317

View File

@ -444,21 +444,42 @@ class User extends Memcached_DataObject
'SELECT notice.* ' . 'SELECT notice.* ' .
'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' . 'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' .
'WHERE subscription.subscriber = %d '; 'WHERE subscription.subscriber = %d ';
$order = null; return Notice::getStream(sprintf($qry, $this->id),
'user:notices_with_friends:' . $this->id,
$offset, $limit, $since_id, $before_id,
$order, $since);
} else if ($enabled === true || } else if ($enabled === true ||
($enabled == 'transitional' && $this->inboxed == 1)) { ($enabled == 'transitional' && $this->inboxed == 1)) {
$qry = $cache = common_memcache();
'SELECT notice.* ' .
'FROM notice JOIN notice_inbox ON notice.id = notice_inbox.notice_id ' . if (!empty($cache)) {
'WHERE notice_inbox.user_id = %d ';
// NOTE: we override ORDER # Get the notices out of the cache
$order = null;
$notices = $cache->get(common_cache_key($cachekey));
# On a cache hit, return a DB-object-like wrapper
if ($notices !== false) {
$wrapper = new ArrayWrapper(array_slice($notices, $offset, $limit));
return $wrapper;
}
}
$inbox = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since);
$ids = array();
while ($inbox->fetch()) {
$ids[] = $inbox->notice_id;
}
$inbox->free();
unset($inbox);
return Notice::getStreamByIds($ids, 'user:notices_with_friends:' . $this->id);
} }
return Notice::getStream(sprintf($qry, $this->id),
'user:notices_with_friends:' . $this->id,
$offset, $limit, $since_id, $before_id,
$order, $since);
} }
function blowFavesCache() function blowFavesCache()