madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r23088: LJSUP-13866: [Internal]Requirements for ...

Committer: sbelyaev
LJSUP-13866: [Internal]Requirements for Redis module (v1.953)
U   trunk/cgi-bin/ljlib.pl
Modified: trunk/cgi-bin/ljlib.pl
===================================================================
--- trunk/cgi-bin/ljlib.pl	2012-10-10 09:29:42 UTC (rev 23087)
+++ trunk/cgi-bin/ljlib.pl	2012-10-10 10:53:42 UTC (rev 23088)
@@ -1730,14 +1730,30 @@
         next unless defined $keyname{$t};
         next if defined $LJ::CACHE_PROP{$t};
         my $tablename = $t eq "rate" ? "ratelist" : "${t}proplist";
+
+        my $cache_key = "props:table:data:$tablename"; 
+        my $cache_data  = LJ::MemCache::get($cache_key);
+        if ($cache_data) {
+            foreach my $p (@$cache_data) {
+                $LJ::CACHE_PROP{$t}->{$p->{'name'}} = $p;
+                $LJ::CACHE_PROPID{$t}->{$p->{'id'}} = $p;
+            }
+            next;
+        } 
+
         $dbr ||= LJ::get_db_writer();
         my $sth = $dbr->prepare("SELECT * FROM $tablename");
         $sth->execute;
+
+        my @data = ();
         while (my $p = $sth->fetchrow_hashref) {
             $p->{'id'} = $p->{$keyname{$t}};
             $LJ::CACHE_PROP{$t}->{$p->{'name'}} = $p;
             $LJ::CACHE_PROPID{$t}->{$p->{'id'}} = $p;
+            push @data, $p;
         }
+
+        LJ::MemCache::set($cache_key, \@data, 180);
     }
 }
 
@@ -1758,6 +1774,7 @@
 {
     my $table = shift;
     my $name = shift;
+
     unless (defined $LJ::CACHE_PROP{$table} && $LJ::CACHE_PROP{$table}->{$name}) {
         $LJ::CACHE_PROP{$table} = undef;
         LJ::load_props($table);

Tags: livejournal, madeon, pl, 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