[livejournal] r22855: 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/BerkeleyDB.pm
Modified: trunk/cgi-bin/LJ/Lang.pm
===================================================================
--- trunk/cgi-bin/LJ/Lang.pm 2012-09-11 09:34:18 UTC (rev 22854)
+++ trunk/cgi-bin/LJ/Lang.pm 2012-09-11 09:49:02 UTC (rev 22855)
@@ -10,6 +10,7 @@
use LJ::LangDatFile;
use LJ::TimeUtil;
+use LJ::LocalCache;
use constant MAXIMUM_ITCODE_LENGTH => 80;
@@ -443,8 +444,10 @@
return set_error( "Error inserting ml_latest: " . $dbh->errstr )
if $dbh->err;
- LJ::MemCache::set( "ml.${lncode}.${dmid}.${itcode}", $text )
- if defined $text;
+ if ($text) {
+ LJ::MemCache::set( "ml.${lncode}.${dmid}.${itcode}", $text );
+ LJ::LocalCache::get_cache()->set( "ml.${lncode}.${dmid}.${itcode}", $text );
+ }
my @langids;
my $langids;
@@ -473,6 +476,7 @@
push @langids, $cid;
LJ::MemCache::delete("ml.$clid->{'lncode'}.${dmid}.${itcode}");
+ LJ::LocalCache::get_cache()->delete("ml.$clid->{'lncode'}.${dmid}.${itcode}");
$rec->($clid);
}
};
@@ -565,6 +569,7 @@
# delete from memcache if lncode is defined
LJ::MemCache::delete("ml.${lncode}.${dmid}.${itcode}") if $lncode;
+ LJ::LocalCache::get_cache()->delete("ml.${lncode}.${dmid}.${itcode}") if $lncode;
return 1;
}
@@ -734,8 +739,20 @@
return \%strings unless %memkeys;
- my $mem = LJ::MemCache::get_multi( keys %memkeys ) || {};
+ 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 ) || {};
+
+ foreach my $key (keys %$mem) {
+ LJ::LocalCache::get_cache()->set($key, $mem->{$key});
+ }
+
+ foreach my $key (keys %$mem_local) {
+ $mem->{$key} = $mem_local->{$key};
+ }
+
## %dbload: lower-case key --> text; text may be empty (but defined) string
my %dbload;
foreach my $cache_key ( keys %memkeys ) {
@@ -799,11 +816,13 @@
if ($text) {
LJ::MemCache::set( $cache_key, $text );
+ LJ::LocalCache::get_cache()->set($cache_key, $text);
} else {
## Do not cache empty values forever - they may be inserted later.
## This is a hack, what we actually need is a mechanism to delete
## the entire language tree for a given $code if it's updated.
LJ::MemCache::set( $cache_key, $text, 24 * 3600 );
+ LJ::LocalCache::get_cache()->set( $cache_key, $text, 24 * 3600 );
}
}
Modified: trunk/cgi-bin/LJ/LocalCache/BerkeleyDB.pm
===================================================================
--- trunk/cgi-bin/LJ/LocalCache/BerkeleyDB.pm 2012-09-11 09:34:18 UTC (rev 22854)
+++ trunk/cgi-bin/LJ/LocalCache/BerkeleyDB.pm 2012-09-11 09:49:02 UTC (rev 22855)
@@ -16,7 +16,6 @@
return $connection;
}
- warn "create connection";
unless(-d $LJ::LJ_LOCAL_BDB_HOME) {
mkdir $LJ::LJ_LOCAL_BDB_HOME;
}
