Committer: sbelyaev
LJSUP-13883: Journal pages optimizaiton : stage 1U trunk/cgi-bin/LJ/S2/RecentPage.pm U trunk/cgi-bin/LJ/Share.pm
Modified: trunk/cgi-bin/LJ/S2/RecentPage.pm =================================================================== --- trunk/cgi-bin/LJ/S2/RecentPage.pm 2012-10-11 11:53:45 UTC (rev 23106) +++ trunk/cgi-bin/LJ/S2/RecentPage.pm 2012-10-11 12:02:43 UTC (rev 23107) @@ -122,6 +122,10 @@ die $err if $err; + # preload js for sharing + LJ::MemCacheProxy::get_multi( + map { "s2:cache:share:js::" . $u->{'userid'} . ":$_" } @itemids ); + ### load the log properties my %logprops = (); my $logtext; Modified: trunk/cgi-bin/LJ/Share.pm =================================================================== --- trunk/cgi-bin/LJ/Share.pm 2012-10-11 11:53:45 UTC (rev 23106) +++ trunk/cgi-bin/LJ/Share.pm 2012-10-11 12:02:43 UTC (rev 23107) @@ -79,10 +79,18 @@ my $cache_key; if ( my $entry = delete $opts->{'entry'} ) { + unless (%$opts) { + $cache_key = 's2:cache:share:js:' . + $entry->journalid . ":" . $entry->jitemid; + + my $data = LJ::MemCacheProxy::get($cache_key); + return $data if $data; + } + $opts->{'title'} = LJ::ejs( LJ::Text->drop_html($entry->subject_raw) ); $opts->{'url'} = $entry->url; - if ($opts->{'title'}){ + if ($opts->{'title'}) { $opts->{'title'} = Encode::decode_utf8($opts->{'title'}); $opts->{'title'} =~ s/\r|\n|\x85|\x{2028}|\x{2029}//gsm; $opts->{'title'} = Encode::encode_utf8($opts->{'title'}); @@ -94,6 +102,7 @@ my $result_text = qq{<script type="text/javascript">LJShare.link($opts_out);</script>}; + LJ::MemCacheProxy::set($cache_key, $result_text, 5 * 60) if $cache_key; return $result_text; }