summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-11-22 14:28:57 -0500
committerEvan Prodromou <evan@prodromou.name>2008-11-22 14:28:57 -0500
commit45f5ef8c8741fe874c5353df4f9f7ff37f6feeda (patch)
treee65a798a974ba83d103a8562078e9036de39fe19 /classes
parent24ad0b3c13c319995b1515f6fb3054334f90fee9 (diff)
if all faves in cache, skip
darcs-hash:20081122192857-84dde-c8fcddd794a8339a53e6a0224bd07f6f86ef3896.gz
Diffstat (limited to 'classes')
-rw-r--r--classes/User.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/classes/User.php b/classes/User.php
index 75dd73315..0c0874091 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -281,6 +281,7 @@ class User extends Memcached_DataObject
# This is the stream of favorite notices, in rev chron
# order. This forces it into cache.
$faves = $this->favoriteNotices(0, NOTICE_CACHE_WINDOW);
+ $cnt = 0;
while ($faves->fetch()) {
if ($faves->id < $notice->id) {
@@ -290,8 +291,15 @@ class User extends Memcached_DataObject
# If it matches a cached notice, then it's a fave
return true;
}
+ $cnt++;
}
- # If it's past the end of the cache window,
+ # If we're not past the end of the cache window,
+ # then the cache has all available faves, so this one
+ # is not a fave.
+ if ($cnt < NOTICE_CACHE_WINDOW) {
+ return false;
+ }
+ # Otherwise, cache doesn't have all faves;
# fall through to the default
}