X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FNotice_tag.php;h=4fd76e8ea85e8c04c9119b370bf3c89a462d7dec;hb=664a82e836b6b5511e925c55983f122508c07232;hp=5b75ff13feb05a22bf48596ac5d73fdaf69f1759;hpb=29146a13f295a13a4ee4470cffaaa7fde6858689;p=quix0rs-gnu-social.git diff --git a/classes/Notice_tag.php b/classes/Notice_tag.php index 5b75ff13fe..4fd76e8ea8 100644 --- a/classes/Notice_tag.php +++ b/classes/Notice_tag.php @@ -1,7 +1,7 @@ delete(common_cache_key('notice_tag:notice_stream:' . $this->tag)); - } - } + + static function getStream($tag, $offset=0, $limit=20) { + + $ids = Notice::stream(array('Notice_tag', '_streamDirect'), + array($tag), + 'notice_tag:notice_ids:' . common_keyize($tag), + $offset, $limit); + + return Notice::getStreamByIds($ids); + } + + function _streamDirect($tag, $offset, $limit, $since_id, $max_id, $since) + { + $nt = new Notice_tag(); + + $nt->tag = $tag; + + $nt->selectAdd(); + $nt->selectAdd('notice_id'); + + if ($since_id != 0) { + $nt->whereAdd('notice_id > ' . $since_id); + } + + if ($max_id != 0) { + $nt->whereAdd('notice_id < ' . $max_id); + } + + if (!is_null($since)) { + $nt->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\''); + } + + $nt->orderBy('notice_id DESC'); + + if (!is_null($offset)) { + $nt->limit($offset, $limit); + } + + $ids = array(); + + if ($nt->find()) { + while ($nt->fetch()) { + $ids[] = $nt->notice_id; + } + } + + return $ids; + } + + function blowCache($blowLast=false) + { + self::blow('notice_tag:notice_ids:%s', common_keyize($this->tag)); + if ($blowLast) { + self::blow('notice_tag:notice_ids:%s;last', common_keyize($this->tag)); + } + } + + function pkeyGet($kv) + { + return Memcached_DataObject::pkeyGet('Notice_tag', $kv); + } }