alf (red_alf) wrote in changelog,
alf
red_alf
changelog

[livejournal] r18867: LJSUP-8569: not update counter of commen...

Committer: afedorov
LJSUP-8569: not update counter of comments

U   trunk/cgi-bin/LJ/Entry.pm
U   trunk/cgi-bin/LJ/Talk.pm
Modified: trunk/cgi-bin/LJ/Entry.pm
===================================================================
--- trunk/cgi-bin/LJ/Entry.pm	2011-04-13 07:11:38 UTC (rev 18866)
+++ trunk/cgi-bin/LJ/Entry.pm	2011-04-13 07:26:17 UTC (rev 18867)
@@ -491,6 +491,12 @@
     return 1;
 }
 
+sub reply_count_memkey {
+    my ($u, $nodeid) = @_;
+    my $userid = LJ::want_userid($u);
+    return [$userid, "rp:$userid:$nodeid"];
+}
+
 sub reply_count {
     my $self = shift;
     my $rc = $self->prop('replycount');
@@ -1890,7 +1896,7 @@
                       $ditemid);
 
         if ($use_cache && $itemnum++ < 50) {
-            LJ::MemCache::add([$jid, "rp:$jid:$item->{'jitemid'}"], $item->{'replycount'});
+            LJ::MemCache::add(LJ::Entry::reply_count_memkey($jid, $item->{'jitemid'}), $item->{'replycount'});
         }
     }
 
@@ -2121,7 +2127,7 @@
         $needprops{$id} = 1;
         $needrc{$id} = 1;
         push @memkeys, [$userid, "logprop:$userid:$id"];
-        push @memkeys, [$userid, "rp:$userid:$id"];
+        push @memkeys, LJ::Entry::reply_count_memkey($userid, $id);
     }
     return unless %needprops || %needrc;
 
@@ -2171,7 +2177,7 @@
         $sth->execute($userid);
         while (my ($jitemid, $rc) = $sth->fetchrow_array) {
             $hashref->{$jitemid}->{'replycount'} = $rc;
-            LJ::MemCache::add([$userid, "rp:$userid:$jitemid"], $rc);
+            LJ::MemCache::add(LJ::Entry::reply_count_memkey($userid, $jitemid), $rc);
         }
     }
 
@@ -2344,7 +2350,7 @@
     
     $value = 1 unless defined $value;
     my $uid = $u->{'userid'};
-    my $memkey = "rp:$uid:$jitemid";
+    my $memkey = LJ::Entry::reply_count_memkey($uid, $jitemid);
 
     # "init" is easiest and needs no lock (called before the entry is live)
     if ($action eq 'init') {

Modified: trunk/cgi-bin/LJ/Talk.pm
===================================================================
--- trunk/cgi-bin/LJ/Talk.pm	2011-04-13 07:11:38 UTC (rev 18866)
+++ trunk/cgi-bin/LJ/Talk.pm	2011-04-13 07:26:17 UTC (rev 18867)
@@ -927,7 +927,7 @@
 
     # we check the replycount in memcache, the value we count, and then fix it up
     # if it seems necessary.
-    my $rp_memkey = $nodetype eq "L" ? [$u->{'userid'}, "rp:$u->{'userid'}:$nodeid"] : undef;
+    my $rp_memkey = $nodetype eq "L" ? LJ::Entry::reply_count_memkey($u, $nodeid) : undef;
     my $rp_count = $rp_memkey ? LJ::MemCache::get($rp_memkey) : 0;
 
     # hook for tests to count memcache gets
@@ -1119,7 +1119,7 @@
     # at the same time we are
     my $nodetype = "L";  # this is only for logitem comment counts
 
-    my $rp_memkey = [$u->{'userid'}, "rp:$u->{'userid'}:$jitemid"];
+    my $rp_memkey = LJ::Entry::reply_count_memkey($u, $jitemid);
     my $rp_count = LJ::MemCache::get($rp_memkey) || 0;
     my $fix_key = "rp_fixed:$u->{userid}:$nodetype:$jitemid:$rp_count";
 
@@ -2283,7 +2283,7 @@
     $jitemid += 0;
     return undef unless $ju && $jitemid;
 
-    my $memkey = [$ju->{'userid'}, "rp:$ju->{'userid'}:$jitemid"];
+    my $memkey = LJ::Entry::reply_count_memkey($ju, $jitemid);
     my $count = LJ::MemCache::get($memkey);
     return $count if $count;
 

Tags: livejournal, pm, red_alf
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