Use cached sources for favorites & repeats info on threaded notice lists
This commit is contained in:
parent
4afa3caae3
commit
0c2c73659c
|
@ -44,6 +44,7 @@ class Fave extends Memcached_DataObject
|
||||||
common_log_db_error($fave, 'INSERT', __FILE__);
|
common_log_db_error($fave, 'INSERT', __FILE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
self::blow('fave:by_notice', $fave->notice_id);
|
||||||
|
|
||||||
Event::handle('EndFavorNotice', array($profile, $notice));
|
Event::handle('EndFavorNotice', array($profile, $notice));
|
||||||
}
|
}
|
||||||
|
@ -61,6 +62,7 @@ class Fave extends Memcached_DataObject
|
||||||
if (Event::handle('StartDisfavorNotice', array($profile, $notice, &$result))) {
|
if (Event::handle('StartDisfavorNotice', array($profile, $notice, &$result))) {
|
||||||
|
|
||||||
$result = parent::delete();
|
$result = parent::delete();
|
||||||
|
self::blow('fave:by_notice', $this->notice_id);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
Event::handle('EndDisfavorNotice', array($profile, $notice));
|
Event::handle('EndDisfavorNotice', array($profile, $notice));
|
||||||
|
@ -208,4 +210,31 @@ class Fave extends Memcached_DataObject
|
||||||
|
|
||||||
return $fav;
|
return $fav;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Grab a list of profile who have favored this notice.
|
||||||
|
*
|
||||||
|
* @return ArrayWrapper masquerading as a Fave
|
||||||
|
*/
|
||||||
|
static function byNotice($noticeId)
|
||||||
|
{
|
||||||
|
$c = self::memcache();
|
||||||
|
$key = Cache::key('fave:by_notice', $noticeId);
|
||||||
|
|
||||||
|
$wrapper = $c->get($key);
|
||||||
|
if (!$wrapper) {
|
||||||
|
// @fixme caching & scalability!
|
||||||
|
$fave = new Fave();
|
||||||
|
$fave->notice_id = $noticeId;
|
||||||
|
$fave->find();
|
||||||
|
|
||||||
|
$profiles = array();
|
||||||
|
while ($fave->fetch()) {
|
||||||
|
$list[] = clone($fave);
|
||||||
|
}
|
||||||
|
$wrapper = new ArrayWrapper($list);
|
||||||
|
$c->set($key, $wrapper);
|
||||||
|
}
|
||||||
|
return $wrapper;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -496,6 +496,8 @@ class Notice extends Memcached_DataObject
|
||||||
if ($this->isPublic()) {
|
if ($this->isPublic()) {
|
||||||
self::blow('public;last');
|
self::blow('public;last');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self::blow('fave:by_notice', $this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** save all urls in the notice to the db
|
/** save all urls in the notice to the db
|
||||||
|
|
|
@ -414,11 +414,7 @@ class ThreadedNoticeListFavesItem extends NoticeListActorsItem
|
||||||
{
|
{
|
||||||
function getProfiles()
|
function getProfiles()
|
||||||
{
|
{
|
||||||
// @fixme caching & scalability!
|
$fave = Fave::byNotice($this->notice->id);
|
||||||
$fave = new Fave();
|
|
||||||
$fave->notice_id = $this->notice->id;
|
|
||||||
$fave->find();
|
|
||||||
|
|
||||||
$profiles = array();
|
$profiles = array();
|
||||||
while ($fave->fetch()) {
|
while ($fave->fetch()) {
|
||||||
$profiles[] = $fave->user_id;
|
$profiles[] = $fave->user_id;
|
||||||
|
@ -469,10 +465,7 @@ class ThreadedNoticeListRepeatsItem extends NoticeListActorsItem
|
||||||
{
|
{
|
||||||
function getProfiles()
|
function getProfiles()
|
||||||
{
|
{
|
||||||
// @fixme caching & scalability!
|
$rep = $this->notice->repeatStream();
|
||||||
$rep = new Notice();
|
|
||||||
$rep->repeat_of = $this->notice->id;
|
|
||||||
$rep->find();
|
|
||||||
|
|
||||||
$profiles = array();
|
$profiles = array();
|
||||||
while ($rep->fetch()) {
|
while ($rep->fetch()) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user