madeon (madeon) wrote in changelog,
madeon
madeon
changelog

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

Committer: sbelyaev
LJSUP-13883: Journal pages optimizaiton : stage 1
U   trunk/cgi-bin/LJ/Share.pm
Modified: trunk/cgi-bin/LJ/Share.pm
===================================================================
--- trunk/cgi-bin/LJ/Share.pm	2012-10-09 13:15:44 UTC (rev 23080)
+++ trunk/cgi-bin/LJ/Share.pm	2012-10-09 13:55:46 UTC (rev 23081)
@@ -77,7 +77,16 @@
 sub render_js {
     my ( $class, $opts ) = @_;
 
+    my $cache_key;
     if ( my $entry = delete $opts->{'entry'} ) {
+        unless (keys %$opts) {
+            $cache_key = 's2:cache:share:js:' . 
+                        $entry->journalid . ":" . $entry->jitemid;
+
+            my $data = LJ::MemCache::get($cache_key);
+            return $data if $data;
+        }
+
         $opts->{'title'}        = LJ::ejs( LJ::Text->drop_html($entry->subject_raw) );
         $opts->{'url'}          = $entry->url;
 
@@ -90,9 +99,11 @@
     }
 
     my $opts_out = LJ::JSON->to_json($opts);
+    my $result_text = 
+        qq{<script type="text/javascript">LJShare.link($opts_out);</script>};
 
-    return
-        qq{<script type="text/javascript">LJShare.link($opts_out);</script>};
+    LJ::MemCache::set($cache_key, $result_text, 5 * 60) if $cache_key;
+    return $result_text;
 }
 
 1;

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