cache groups per notice
This commit is contained in:
parent
d9ca956ecf
commit
44c64816a5
@ -1250,10 +1250,15 @@ class Notice extends Memcached_DataObject
|
||||
return array();
|
||||
}
|
||||
|
||||
// XXX: cache me
|
||||
$ids = array();
|
||||
|
||||
$groups = array();
|
||||
$keypart = sprintf('notice:groups:%d', $this->id);
|
||||
|
||||
$idstr = self::cacheGet($keypart);
|
||||
|
||||
if ($idstr !== false) {
|
||||
$ids = explode(',', $idstr);
|
||||
} else {
|
||||
$gi = new Group_inbox();
|
||||
|
||||
$gi->selectAdd();
|
||||
@ -1263,14 +1268,21 @@ class Notice extends Memcached_DataObject
|
||||
|
||||
if ($gi->find()) {
|
||||
while ($gi->fetch()) {
|
||||
$group = User_group::staticGet('id', $gi->group_id);
|
||||
$ids[] = $gi->group_id;
|
||||
}
|
||||
}
|
||||
|
||||
self::cacheSet($keypart, implode(',', $ids));
|
||||
}
|
||||
|
||||
$groups = array();
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$group = User_group::staticGet('id', $id);
|
||||
if ($group) {
|
||||
$groups[] = $group;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$gi->free();
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user