madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r23126: LJSUP-13883: Journal pages optimizaiton ...

Committer: sbelyaev
LJSUP-13883: Journal pages optimizaiton : stage 1
U   trunk/cgi-bin/LJ/NotificationInbox.pm
Modified: trunk/cgi-bin/LJ/NotificationInbox.pm
===================================================================
--- trunk/cgi-bin/LJ/NotificationInbox.pm	2012-10-12 12:32:08 UTC (rev 23125)
+++ trunk/cgi-bin/LJ/NotificationInbox.pm	2012-10-12 13:01:55 UTC (rev 23126)
@@ -195,9 +195,16 @@
     }
 
     my $u = $self->owner;
-    return $self->{count} = $u->selectrow_array
-        ("SELECT COUNT(*) FROM notifyqueue WHERE userid=?",
-         undef, $u->id);
+    
+    my $count = LJ::MemCache::get($self->_count_memkey);
+    unless ($count) {
+         $count = $u->selectrow_array
+                    ("SELECT COUNT(*) FROM notifyqueue WHERE userid=?",
+                     undef, $u->id);
+        LJ::MemCache::set($self->_count_memkey, $count, 3600);
+    }
+
+    return $self->{count} = $count;
 }
 
 # returns number of unread items in inbox
@@ -301,6 +308,12 @@
     return [$userid, "inbox:$userid"];
 }
 
+sub _count_memkey {
+    my $self = shift;
+    my $userid = $self->u->id;
+    return [$userid, "inbox:cnt:$userid"];
+}
+
 sub _unread_memkey {
     my $self = shift;
     my $userid = $self->u->id;
@@ -344,6 +357,7 @@
     $self->{items} = undef;
 
     LJ::MemCache::delete($self->_memkey);
+    LJ::MemCache::delete($self->_count_memkey);
     LJ::MemCache::delete($self->_unread_memkey);
 }
 

Tags: livejournal, madeon, pm, sbelyaev
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments