Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[fotobilder] r1443: Adding caching to proplist table

Committer: gariev
Adding caching to proplist table
U   trunk/lib/fotobilder.pl
Modified: trunk/lib/fotobilder.pl
===================================================================
--- trunk/lib/fotobilder.pl	2011-05-24 03:38:38 UTC (rev 1442)
+++ trunk/lib/fotobilder.pl	2011-05-25 04:10:51 UTC (rev 1443)
@@ -1362,15 +1362,22 @@
 sub get_props  # DEPRECATED
 {
     return $FB::CACHED_PROPS if $FB::CACHED_PROPS;
+
+    my $memkey = "fb:proplist";
+    $FB::CACHED_PROPS = FB::MemCache::get($memkey);
+    return $FB::CACHED_PROPS if $FB::CACHED_PROPS;
+
     my %props;
-    my $dbr = FB::get_db_reader();
+    my $dbr = FB::get_db_writer();
     my $sth = $dbr->prepare("SELECT propid, propname FROM proplist");
     $sth->execute;
     while (my ($id, $name) = $sth->fetchrow_array) {
         $props{$id} = $name;
         $props{$name} = $id;
     }
+    return if $sth->err; ## don't cache incomplete data
     $FB::CACHED_PROPS = \%props;
+    FB::MemCache::set($memkey, $FB::CACHED_PROPS, 3600);
     return $FB::CACHED_PROPS;
 }
 

Tags: fotobilder, gariev, pl
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