changeset 298:b3b845d30d4b

new cache mechanism
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sun, 07 Dec 2008 16:40:04 +0800
parents 073442284ec1
children 5fc26f2af95b
files Ikariam.pm spy.pl
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Ikariam.pm	Sun Dec 07 15:12:33 2008 +0800
+++ b/Ikariam.pm	Sun Dec 07 16:40:04 2008 +0800
@@ -113,6 +113,7 @@
 use HTTP::Cookies;
 use WWW::Mechanize;
 use XML::LibXML qw(:encoding);
+use YAML qw/LoadFile Dump DumpFile/;
 use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
 use POSIX;
 use utf8;
@@ -133,6 +134,7 @@
         debug => undef,
     };
 
+
     # if debug
     LWP::Debug::level('+trace');
 
@@ -1298,9 +1300,12 @@
     if($#cities<0) {
         die ("login failed\n");
     }
-    foreach(@cities) {
+    foreach (@cities) {
         $self->{'cities'}->{$_} = {};
         $self->{'cities'}->{$_}->{id} = $_;
+        if(-f "city-$_-dump.yaml") {
+            $self->{'cities'}->{$_} = LoadFile("city-$_-dump.yaml");
+        }
     }
 }
 
--- a/spy.pl	Sun Dec 07 15:12:33 2008 +0800
+++ b/spy.pl	Sun Dec 07 16:40:04 2008 +0800
@@ -11,8 +11,7 @@
 # $i->check();
 foreach (glob("city-*-dump.yaml")) {
     my $city = LoadFile($_);
-    $i->{'cities'}->{$city->{id}} = $city;
- 
+    # $i->{'cities'}->{$city->{id}} = $city;
     my $spydata = $i->checkSafeHouse($city->{id});
     foreach (keys(%{$spydata})) {
         DumpFile("spy-$_-dump.yaml", $spydata->{$_});