madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r22856: LJSUP-13604: Local cache [internal]

Committer: sbelyaev
LJSUP-13604: Local cache [internal]
U   trunk/cgi-bin/LJ/Lang.pm
U   trunk/cgi-bin/LJ/LocalCache.pm
Modified: trunk/cgi-bin/LJ/Lang.pm
===================================================================
--- trunk/cgi-bin/LJ/Lang.pm	2012-09-11 09:49:02 UTC (rev 22855)
+++ trunk/cgi-bin/LJ/Lang.pm	2012-09-11 10:09:55 UTC (rev 22856)
@@ -739,19 +739,25 @@
 
     return \%strings unless %memkeys;
 
-    my @keys_memcache = ();
-    my @keys = keys %memkeys;
+    my $mem = {};
+    if (0 && LJ::is_enabled('local_cache')) {
+        my @keys_memcache = ();
+        my @keys = keys %memkeys;
 
-    my $mem_local = LJ::LocalCache::get_cache()->get_multi( \@keys, \@keys_memcache );
-    my $mem = LJ::MemCache::get_multi( @keys_memcache ) || {};
+        my $mem_local = LJ::LocalCache::get_cache()->get_multi( \@keys, \@keys_memcache );
+           $mem = LJ::MemCache::get_multi( @keys_memcache ) || {};
 
-    foreach my $key (keys %$mem) {
-        LJ::LocalCache::get_cache()->set($key, $mem->{$key});
-    }
+        foreach my $key (keys %$mem) {
+            LJ::LocalCache::get_cache()->set($key, $mem->{$key});
+        }
 
-    foreach my $key (keys %$mem_local) {
-        $mem->{$key} = $mem_local->{$key};
+        foreach my $key (keys %$mem_local) {
+            $mem->{$key} = $mem_local->{$key};
+        }
+    } else {
+        $mem = LJ::MemCache::get_multi( keys %memkeys ) || {};
     }
+       
 
     ## %dbload: lower-case key --> text; text may be empty (but defined) string
     my %dbload;

Modified: trunk/cgi-bin/LJ/LocalCache.pm
===================================================================
--- trunk/cgi-bin/LJ/LocalCache.pm	2012-09-11 09:49:02 UTC (rev 22855)
+++ trunk/cgi-bin/LJ/LocalCache.pm	2012-09-11 10:09:55 UTC (rev 22856)
@@ -6,10 +6,19 @@
 
 my @SUBCLASSES = LJ::ModuleLoader->module_subclasses(__PACKAGE__);
 
-foreach my $class (@SUBCLASSES) {
-    eval "use $class";
-    if ($@) {
-        die "Error loading package $class: $@" 
+my $loaded = 0;
+
+sub __load_packages {
+    return if $loaded;
+    if (LJ::is_enabled("local_cache")) {
+        foreach my $class (@SUBCLASSES) {
+            eval "use $class";
+            if ($@) {
+                warn "Error loading package $class: $@" 
+            }
+        }
+
+        $loaded = 1;
     }
 }
 
@@ -17,6 +26,8 @@
     my ($handler) = @_;
     $handler ||= $LJ::LOCAL_CACHE_DEFAULT_HANDLER;
 
+    return 'LJ::LocalCache' if !LJ::is_enabled("local_cache");
+    __load_packages();
     return "LJ::LocalCache::$handler";
 }
 
@@ -27,6 +38,7 @@
 
 sub get_multi {
     my ($class, $keys, $not_fetched_keys) = @_;
+    $not_fetched_keys = $keys;
     return undef;
 }
 

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