madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[ljcom] r12459: LJSUP-13301: Main page optimization

Committer: sbelyaev
LJSUP-13301: Main page optimization
U   trunk/cgi-bin/LJ/Nav.pm
Modified: trunk/cgi-bin/LJ/Nav.pm
===================================================================
--- trunk/cgi-bin/LJ/Nav.pm	2012-08-14 11:37:05 UTC (rev 12458)
+++ trunk/cgi-bin/LJ/Nav.pm	2012-08-14 13:17:06 UTC (rev 12459)
@@ -6,6 +6,8 @@
 
 use LJ::Lang qw( ml );
 
+use constant { NAV_CACHE_TIME => 60*60*2, };
+
 # return the list of menus and sub-items that make up the LJ nav bar
 # (class method)
 sub navbar {
@@ -19,6 +21,14 @@
 
     $scheme ||= "default";
     $opts   ||= {};
+    
+    my $journal      = $remote ? $remote->userid : 'non';
+    my $memcache_key = "navbar:$scheme:$journal:" . $LJ::CURRENT_VERSION;
+   
+    my $cached = LJ::MemCache::get($memcache_key);
+    if ($cached) {
+        return @{LJ::JSON->from_json($cached)};
+    }
 
     my @nav;
 
@@ -49,6 +59,8 @@
         push @nav_filtered, $section;
     }
 
+    my $cache_data = LJ::JSON->to_json(\@nav_filtered);
+    LJ::MemCache::set($memcache_key, $cache_data, NAV_CACHE_TIME);  
     return @nav_filtered;
 }
 

Tags: ljcom, 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