Mercurial > eagle-eye
diff scan.pl @ 16:59f2c435760c
implemented cached by timing.
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Wed, 08 Oct 2008 15:24:21 +0800 |
parents | 8b7bc598ba06 |
children | fd44e3a1f800 |
line wrap: on
line diff
--- a/scan.pl Wed Oct 08 12:56:40 2008 +0800 +++ b/scan.pl Wed Oct 08 15:24:21 2008 +0800 @@ -11,6 +11,7 @@ foreach my $city (@cities) { $city->{island} = $island; + $city->{'time'} = time; if(my $c = Ikariam::Cities->retrieve($city->{cityId})) { foreach my $i (keys(%$city)) { @@ -44,6 +45,7 @@ { # print(Dumper($user)); printf("Saving user %s\n", $user->{'name'}); + $user->{'time'} = time; if(my $c = Ikariam::User->retrieve($user->{id})) { foreach my $i (keys(%$user)) { @@ -81,17 +83,22 @@ foreach my $island (@islands) { printf("checking island %d\n", $island->{id}); - if(my $c = Ikariam::Island->retrieve($island->{id})) { - foreach my $i (keys(%$island)) { - eval($c->$i($island->{$i})); - } - } else { - Ikariam::Island->insert($island); - } # scanning the island - my @cities = $i->viewIsland($island->{id}); - saveCities($island->{id}, @cities); + if($island->{time} < (time - 60*60*12 )) + { + my @cities = $i->viewIsland($island->{id}); + saveCities($island->{id}, @cities); + + $island->{'time'} = time; + if(my $c = Ikariam::Island->retrieve($island->{id})) { + foreach my $i (keys(%$island)) { + eval($c->$i($island->{$i})); + } + } else { + Ikariam::Island->insert($island); + } + } } $i->logout; # $i->getCityInfo();