vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[livejournal] r22754: LJSUP-13445: Home page optimization: sta...

Committer: vad
LJSUP-13445: Home page optimization: stage 2
U   trunk/cgi-bin/LJ/Lang.pm
Modified: trunk/cgi-bin/LJ/Lang.pm
===================================================================
--- trunk/cgi-bin/LJ/Lang.pm	2012-08-28 12:32:57 UTC (rev 22753)
+++ trunk/cgi-bin/LJ/Lang.pm	2012-08-28 12:37:33 UTC (rev 22754)
@@ -814,8 +814,16 @@
     my @langs = @_;
     push @langs, @LJ::LANGS unless @langs;
 
+    ## check in-memory cache first
+    if ($LJ::_CACHE_LANG_NAMES and (time - $LJ::_CACHE_LANG_NAMES->{cached_at} < 3660)){
+        return $LJ::_CACHE_LANG_NAMES->{data};
+    }
+
     my $list = LJ::MemCache::get("langnames");
-    return $list if $list;
+    if ($list){
+        $LJ::_CACHE_LANG_NAMES = { cached_at => time, data => $list }; ## add to process memory cache
+        return $list;
+    }
 
     $list = [];
     foreach my $code (@langs) {
@@ -833,6 +841,9 @@
     ## cache name on 5 min
     LJ::MemCache::set( 'langnames' => $list, 3660 );
 
+    ## cache in process memory for the same time as in memcache
+    $LJ::_CACHE_LANG_NAMES = { cached_at => time, data => $list };
+
     return $list;
 }
 

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