diff options
author | Evan Prodromou <evan@prodromou.name> | 2008-11-23 19:32:40 -0500 |
---|---|---|
committer | Evan Prodromou <evan@prodromou.name> | 2008-11-23 19:32:40 -0500 |
commit | 577b54c2afda7c817d01af493b68f09f35e360a1 (patch) | |
tree | b8db0b5c42659d4ea99cc4037fb7a761f40a029c /classes/Notice.php | |
parent | 45f5ef8c8741fe874c5353df4f9f7ff37f6feeda (diff) |
blow last caches on notice delete
We do some extra caching of streams, at ';last'. If a notice is
deleted, we need to blow those caches, too. So, this deletes them.
darcs-hash:20081124003240-84dde-aa4561e5e68b0ccc0598ac86294ea54f9be5775a.gz
Diffstat (limited to 'classes/Notice.php')
-rw-r--r-- | classes/Notice.php | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/classes/Notice.php b/classes/Notice.php index 79428a1f9..98a77e20d 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -58,8 +58,8 @@ class Notice extends Memcached_DataObject } function delete() { - $this->blowCaches(); - $this->blowFavesCache(); + $this->blowCaches(true); + $this->blowFavesCache(true); $this->blowInboxes(); parent::delete(); } @@ -137,15 +137,15 @@ class Notice extends Memcached_DataObject return $notice; } - function blowCaches() { - $this->blowSubsCache(); - $this->blowNoticeCache(); - $this->blowRepliesCache(); - $this->blowPublicCache(); - $this->blowTagCache(); + function blowCaches($blowLast=false) { + $this->blowSubsCache($blowLast); + $this->blowNoticeCache($blowLast); + $this->blowRepliesCache($blowLast); + $this->blowPublicCache($blowLast); + $this->blowTagCache($blowLast); } - function blowTagCache() { + function blowTagCache($blowLast=false) { $cache = common_memcache(); if ($cache) { $tag = new Notice_tag(); @@ -153,6 +153,9 @@ class Notice extends Memcached_DataObject if ($tag->find()) { while ($tag->fetch()) { $cache->delete(common_cache_key('notice_tag:notice_stream:' . $tag->tag)); + if ($blowLast) { + $cache->delete(common_cache_key('notice_tag:notice_stream:' . $tag->tag . ';last')); + } } } $tag->free(); @@ -160,7 +163,7 @@ class Notice extends Memcached_DataObject } } - function blowSubsCache() { + function blowSubsCache($blowLast=false) { $cache = common_memcache(); if ($cache) { $user = new User(); @@ -171,23 +174,28 @@ class Notice extends Memcached_DataObject while ($user->fetch()) { $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id)); + if ($blowLast) { + $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id . ';last')); + } } - $user->free(); unset($user); } } - function blowNoticeCache() { + function blowNoticeCache($blowLast=false) { if ($this->is_local) { $cache = common_memcache(); if ($cache) { $cache->delete(common_cache_key('user:notices:'.$this->profile_id)); + if ($blowLast) { + $cache->delete(common_cache_key('user:notices:'.$this->profile_id.';last')); + } } } } - function blowRepliesCache() { + function blowRepliesCache($blowLast=false) { $cache = common_memcache(); if ($cache) { $reply = new Reply(); @@ -195,6 +203,9 @@ class Notice extends Memcached_DataObject if ($reply->find()) { while ($reply->fetch()) { $cache->delete(common_cache_key('user:replies:'.$reply->profile_id)); + if ($blowLast) { + $cache->delete(common_cache_key('user:replies:'.$reply->profile_id.';last')); + } } } $reply->free(); @@ -202,16 +213,19 @@ class Notice extends Memcached_DataObject } } - function blowPublicCache() { + function blowPublicCache($blowLast=false) { if ($this->is_local) { $cache = common_memcache(); if ($cache) { $cache->delete(common_cache_key('public')); + if ($blowLast) { + $cache->delete(common_cache_key('public').';last'); + } } } } - function blowFavesCache() { + function blowFavesCache($blowLast=false) { $cache = common_memcache(); if ($cache) { $fave = new Fave(); @@ -219,6 +233,9 @@ class Notice extends Memcached_DataObject if ($fave->find()) { while ($fave->fetch()) { $cache->delete(common_cache_key('user:faves:'.$fave->user_id)); + if ($blowLast) { + $cache->delete(common_cache_key('user:faves:'.$fave->user_id.';last')); + } } } $fave->free(); |