static function getStreamDirect($qry, $offset, $limit) {
- $qry .= 'ORDER BY notice.created DESC, notice.id DESC ';
+ $qry .= ' ORDER BY notice.created DESC, notice.id DESC ';
if(common_config('db','type')=='pgsql') {
- $qry .= 'LIMIT ' . $limit . ' OFFSET ' . $offset;
+ $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
- $qry .= 'LIMIT ' . $offset . ', ' . $limit;
+ $qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$notice = new Notice();
# Get the cache; if we can't, just go to the DB
$cache = common_memcache();
+
if (!$cache) {
return Notice::getStreamDirect($qry, $offset, $limit);
# On a cache hit, return a DB-object-like wrapper
- if ($notices) {
+ if ($notices !== FALSE) {
$wrapper = new NoticeWrapper(array_slice($notices, $offset, $limit));
return $wrapper;
}
# Store the array in the cache for next time
- $cache->set(common_cache_key($cachekey), $notices);
+ $result = $cache->set(common_cache_key($cachekey), $notices);
# return a wrapper of the array for use now
$wrapper = new NoticeWrapper(array_slice($notices, $offset, $limit));
+
return $wrapper;
}