alf (red_alf) wrote in changelog,
alf
red_alf
changelog

[livejournal] r21698: LJSUP-10900: Implement MessagePack proto...

Committer: afedorov
LJSUP-10900: Implement MessagePack protocol driver to access to Relation Service.

U   trunk/cgi-bin/LJ/RelationService/MysqlAPI.pm
U   trunk/cgi-bin/LJ/RelationService.pm
U   trunk/cgi-bin/ljrelation.pl
Modified: trunk/cgi-bin/LJ/RelationService/MysqlAPI.pm
===================================================================
--- trunk/cgi-bin/LJ/RelationService/MysqlAPI.pm	2012-04-11 13:24:58 UTC (rev 21697)
+++ trunk/cgi-bin/LJ/RelationService/MysqlAPI.pm	2012-04-11 13:44:06 UTC (rev 21698)
@@ -767,4 +767,31 @@
     return $LJ::REQ_CACHE_REL{$key} = $dbval;
 }
 
+sub get_groupmask {
+    my $class  = shift;
+    my $u      = shift;
+    my $friend = shift;
+    my %opts   = @_;
+    
+    return 0 unless $u && $friend;
+ 
+    my $jid = LJ::want_userid($u);
+    my $fid = LJ::want_userid($friend);
+    return 0 unless $jid && $fid;
+
+    my $memkey = [$jid,"frgmask:$jid:$fid"];
+    my $mask = LJ::MemCache::get($memkey);
+    unless (defined $mask) {
+        my $dbw = LJ::get_db_writer();
+        die "No database reader available" unless $dbw;
+
+        $mask = $dbw->selectrow_array("SELECT groupmask FROM friends ".
+                                      "WHERE userid=? AND friendid=?",
+                                      undef, $jid, $fid);
+        LJ::MemCache::set($memkey, $mask+0, time()+60*15);
+    }
+
+    return $mask+0;  # force it to a numeric scalar
+}
+
 1;

Modified: trunk/cgi-bin/LJ/RelationService.pm
===================================================================
--- trunk/cgi-bin/LJ/RelationService.pm	2012-04-11 13:24:58 UTC (rev 21697)
+++ trunk/cgi-bin/LJ/RelationService.pm	2012-04-11 13:44:06 UTC (rev 21698)
@@ -185,4 +185,29 @@
     return $interface->is_relation_to($u, $friend, $type, %opts);    
 }
 
+sub get_groupmask {
+    my $class  = shift;
+    my $u      = shift;
+    my $friend = shift;
+    my %opts   = @_;
+    
+    my $type = $opts{type} || 'F';
+    
+    $u = LJ::want_user($u);
+    $friend = LJ::want_user($friend);
+    
+    return 0 unless $u && $friend && $type;
+
+    if ($class->_load_alt_api('read', $type)) {
+        my $alt = $class->alt_api($u);
+        if ($alt) {
+            $alt->get_groupmask($u, $friend, $type, %opts);
+        }
+    }
+
+    my $interface = $class->relation_api($u);
+    return $interface->get_groupmask($u, $friend, %opts);    
+}
+
+
 1;

Modified: trunk/cgi-bin/ljrelation.pl
===================================================================
--- trunk/cgi-bin/ljrelation.pl	2012-04-11 13:24:58 UTC (rev 21697)
+++ trunk/cgi-bin/ljrelation.pl	2012-04-11 13:44:06 UTC (rev 21698)
@@ -69,27 +69,10 @@
 
 sub get_groupmask
 {
-    # TAG:FR:ljlib:get_groupmask
     my ($journal, $remote) = @_;
     return 0 unless $journal && $remote;
 
-    my $jid = LJ::want_userid($journal);
-    my $fid = LJ::want_userid($remote);
-    return 0 unless $jid && $fid;
-
-    my $memkey = [$jid,"frgmask:$jid:$fid"];
-    my $mask = LJ::MemCache::get($memkey);
-    unless (defined $mask) {
-        my $dbw = LJ::get_db_writer();
-        die "No database reader available" unless $dbw;
-
-        $mask = $dbw->selectrow_array("SELECT groupmask FROM friends ".
-                                      "WHERE userid=? AND friendid=?",
-                                      undef, $jid, $fid);
-        LJ::MemCache::set($memkey, $mask+0, time()+60*15);
-    }
-
-    return $mask+0;  # force it to a numeric scalar
+    return LJ::RelationService->get_groupmask($journal, $remote);
 }
 
 

Tags: afedorov, livejournal, pl, 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