- $att[] = clone($f);
- }
- }
- return $att;
- }
-
- function blowCaches($blowLast=false)
- {
- $this->blowSubsCache($blowLast);
- $this->blowNoticeCache($blowLast);
- $this->blowRepliesCache($blowLast);
- $this->blowPublicCache($blowLast);
- $this->blowTagCache($blowLast);
- $this->blowGroupCache($blowLast);
- $this->blowConversationCache($blowLast);
- $this->blowRepeatCache();
- $profile = Profile::staticGet($this->profile_id);
- $profile->blowNoticeCount();
- }
-
- function blowRepeatCache()
- {
- if (!empty($this->repeat_of)) {
- $cache = common_memcache();
- if (!empty($cache)) {
- // XXX: only blow if <100 in cache
- $ck = common_cache_key('notice:repeats:'.$this->repeat_of);
- $result = $cache->delete($ck);
-
- $user = User::staticGet('id', $this->profile_id);
-
- if (!empty($user)) {
- $uk = common_cache_key('user:repeated_by_me:'.$user->id);
- $cache->delete($uk);
- $user->free();
- unset($user);
- }
-
- $original = Notice::staticGet('id', $this->repeat_of);
-
- if (!empty($original)) {
- $originalUser = User::staticGet('id', $original->profile_id);
- if (!empty($originalUser)) {
- $ouk = common_cache_key('user:repeats_of_me:'.$originalUser->id);
- $cache->delete($ouk);
- $originalUser->free();
- unset($originalUser);
- }
- $original->free();
- unset($original);
- }
-
- $ni->free();
- unset($ni);
- }
- }
- }
-
- function blowConversationCache($blowLast=false)
- {
- $cache = common_memcache();
- if ($cache) {
- $ck = common_cache_key('notice:conversation_ids:'.$this->conversation);
- $cache->delete($ck);
- if ($blowLast) {
- $cache->delete($ck.';last');
- }
- }
- }
-
- function blowGroupCache($blowLast=false)
- {
- $cache = common_memcache();
- if ($cache) {
- $group_inbox = new Group_inbox();
- $group_inbox->notice_id = $this->id;
- if ($group_inbox->find()) {
- while ($group_inbox->fetch()) {
- $cache->delete(common_cache_key('user_group:notice_ids:' . $group_inbox->group_id));
- if ($blowLast) {
- $cache->delete(common_cache_key('user_group:notice_ids:' . $group_inbox->group_id.';last'));
- }
- $member = new Group_member();
- $member->group_id = $group_inbox->group_id;
- if ($member->find()) {
- while ($member->fetch()) {
- $cache->delete(common_cache_key('notice_inbox:by_user:' . $member->profile_id));
- $cache->delete(common_cache_key('notice_inbox:by_user_own:' . $member->profile_id));
- if (empty($this->repeat_of)) {
- $cache->delete(common_cache_key('user:friends_timeline:' . $member->profile_id));
- $cache->delete(common_cache_key('user:friends_timeline_own:' . $member->profile_id));
- }
- if ($blowLast) {
- $cache->delete(common_cache_key('notice_inbox:by_user:' . $member->profile_id . ';last'));
- $cache->delete(common_cache_key('notice_inbox:by_user_own:' . $member->profile_id . ';last'));
- if (empty($this->repeat_of)) {
- $cache->delete(common_cache_key('user:friends_timeline:' . $member->profile_id . ';last'));
- $cache->delete(common_cache_key('user:friends_timeline_own:' . $member->profile_id . ';last'));
- }
- }
- }
- }
- }
- }
- $group_inbox->free();
- unset($group_inbox);
- }
- }
-
- function blowTagCache($blowLast=false)
- {
- $cache = common_memcache();
- if ($cache) {
- $tag = new Notice_tag();
- $tag->notice_id = $this->id;
- if ($tag->find()) {
- while ($tag->fetch()) {
- $tag->blowCache($blowLast);
- $ck = 'profile:notice_ids_tagged:' . $this->profile_id . ':' . $tag->tag;
-
- $cache->delete($ck);
- if ($blowLast) {
- $cache->delete($ck . ';last');
- }
- }
- }
- $tag->free();
- unset($tag);
- }
- }
-
- function blowSubsCache($blowLast=false)
- {
- $cache = common_memcache();
- if ($cache) {
- $user = new User();
-
- $UT = common_config('db','type')=='pgsql'?'"user"':'user';
- $user->query('SELECT id ' .
-
- "FROM $UT JOIN subscription ON $UT.id = subscription.subscriber " .
- 'WHERE subscription.subscribed = ' . $this->profile_id);
-
- while ($user->fetch()) {
- $cache->delete(common_cache_key('notice_inbox:by_user:'.$user->id));
- $cache->delete(common_cache_key('notice_inbox:by_user_own:'.$user->id));
- if (empty($this->repeat_of)) {
- $cache->delete(common_cache_key('user:friends_timeline:'.$user->id));
- $cache->delete(common_cache_key('user:friends_timeline_own:'.$user->id));
- }
- if ($blowLast) {
- $cache->delete(common_cache_key('notice_inbox:by_user:'.$user->id.';last'));
- $cache->delete(common_cache_key('notice_inbox:by_user_own:'.$user->id.';last'));
- if (empty($this->repeat_of)) {
- $cache->delete(common_cache_key('user:friends_timeline:'.$user->id.';last'));
- $cache->delete(common_cache_key('user:friends_timeline_own:'.$user->id.';last'));
- }
- }
- }
- $user->free();
- unset($user);
- }
- }
-
- function blowNoticeCache($blowLast=false)
- {
- if ($this->is_local) {
- $cache = common_memcache();
- if (!empty($cache)) {
- $cache->delete(common_cache_key('profile:notice_ids:'.$this->profile_id));
- if ($blowLast) {
- $cache->delete(common_cache_key('profile:notice_ids:'.$this->profile_id.';last'));
- }
- }
- }
- }
-
- function blowRepliesCache($blowLast=false)
- {
- $cache = common_memcache();
- if ($cache) {
- $reply = new Reply();
- $reply->notice_id = $this->id;
- if ($reply->find()) {
- while ($reply->fetch()) {
- $cache->delete(common_cache_key('reply:stream:'.$reply->profile_id));
- if ($blowLast) {
- $cache->delete(common_cache_key('reply:stream:'.$reply->profile_id.';last'));
- }
- }
- }
- $reply->free();
- unset($reply);
- }
- }
-
- function blowPublicCache($blowLast=false)
- {
- if ($this->is_local == Notice::LOCAL_PUBLIC) {
- $cache = common_memcache();
- if ($cache) {
- $cache->delete(common_cache_key('public'));
- if ($blowLast) {
- $cache->delete(common_cache_key('public').';last');
- }
- }
- }
- }
-
- function blowFavesCache($blowLast=false)
- {
- $cache = common_memcache();
- if ($cache) {
- $fave = new Fave();
- $fave->notice_id = $this->id;
- if ($fave->find()) {
- while ($fave->fetch()) {
- $cache->delete(common_cache_key('fave:ids_by_user:'.$fave->user_id));
- $cache->delete(common_cache_key('fave:by_user_own:'.$fave->user_id));
- if ($blowLast) {
- $cache->delete(common_cache_key('fave:ids_by_user:'.$fave->user_id.';last'));
- $cache->delete(common_cache_key('fave:by_user_own:'.$fave->user_id.';last'));
- }