cache tags per notice

This commit is contained in:
Evan Prodromou 2011-04-06 23:25:24 -04:00
parent 59d0e2f373
commit d3d0ec5ebe

View File

@ -2004,6 +2004,14 @@ class Notice extends Memcached_DataObject
public function getTags() public function getTags()
{ {
$tags = array(); $tags = array();
$keypart = sprintf('notice:tags:%d', $this->id);
$tagstr = self::cacheGet($keypart);
if ($tagstr !== false) {
$tags = explode(',', $tagstr);
} else {
$tag = new Notice_tag(); $tag = new Notice_tag();
$tag->notice_id = $this->id; $tag->notice_id = $this->id;
if ($tag->find()) { if ($tag->find()) {
@ -2011,7 +2019,9 @@ class Notice extends Memcached_DataObject
$tags[] = $tag->tag; $tags[] = $tag->tag;
} }
} }
$tag->free(); self::cacheSet($keypart, implode(',', $tags));
}
return $tags; return $tags;
} }