Committer: gariev
Fix for memcache issue: cookie contained spaces so the memcache key was invalidU trunk/lib/FotoBilder/Auth/LiveJournal.pm
Modified: trunk/lib/FotoBilder/Auth/LiveJournal.pm =================================================================== --- trunk/lib/FotoBilder/Auth/LiveJournal.pm 2011-06-10 08:09:48 UTC (rev 1447) +++ trunk/lib/FotoBilder/Auth/LiveJournal.pm 2011-06-16 09:11:38 UTC (rev 1448) @@ -228,8 +228,9 @@ my $exp_time = 120; # check memcache - my $memkey = "fbsess:$session"; # contains [time, uid] - if (my $data = FB::MemCache::get($memkey)) { + my $memkey = "fbsess:$session"; $memkey =~ s!//.*!!; + my $data = FB::MemCache::get($memkey); # contains [time, uid] + if ($data) { print STDERR "memcached userid=$data->[1] saved at $data->[0]\n" if $FB::DEBUG; if ($data->[0]>time-$exp_time) { @@ -241,8 +242,8 @@ # see if we already validated this within the last two minutes. # if so, don't bug the real livejournal installation my $db = FB::get_db_writer(); - my $uid = $db->selectrow_array(qq{ - SELECT userid FROM domainauthcache + my ($uid, $timegood) = $db->selectrow_array(qq{ + SELECT userid, timegood FROM domainauthcache WHERE domainid=? AND sessionkey=? AND timegood >= UNIX_TIMESTAMP() - $exp_time }, undef, $self->{'domainid'}, $session); @@ -251,7 +252,10 @@ if ($uid) { my $u = FB::load_userid($uid, @lj_props); print STDERR "u=$u\n" if $FB::DEBUG; - return $u if $u; + if ($u) { + FB::MemCache::set($memkey, [$timegood, $u->{'userid'}], $exp_time); + return $u; + } } # do some clean-up (lazy, not every request)