flush lru cache on reload
authorminima <minima>
Tue, 29 Oct 2002 15:35:29 +0000 (15:35 +0000)
committerminima <minima>
Tue, 29 Oct 2002 15:35:29 +0000 (15:35 +0000)
Changes
perl/Chain.pm
perl/Prefix.pm

diff --git a/Changes b/Changes
index 9418f1f60ed529dac0024e29d44207a544487782..62800dd033de06af5b7509f69483d19a80738017 100644 (file)
--- a/Changes
+++ b/Changes
@@ -2,6 +2,7 @@
 1. make sh/log et al a bit more efficient.
 2. fix dupe message in dx.
 3. update cty.dat to the latest, add k8T, K8O to KH8 and TX5BTY to FO/A
+4. clear cache on reload of prefixes
 25Oct02=======================================================================
 1. remove the dupefile automatically if it becomes corrupted
 2. instrument the startup slightly more
index c4fa99a79b5d45690e11e66fb9c5eee1b5cd171b..c065d17a62305b6c9fb224f0eb51a45b5ab34c1b 100644 (file)
@@ -156,6 +156,13 @@ sub count
        return $count;
 }
 
+sub close
+{
+       my $base = shift;
+       $base->flush;
+       $base->[PREV] = $base->[NEXT] = undef;
+}
+
 1;
 __END__
 # Below is the stub of documentation for your module. You better edit it!
index 5733ff0254c689dabde03a16371b1f412b442d48..6f1c1f29a8849f23b4f753d6ab02eae75a905435 100644 (file)
@@ -31,9 +31,7 @@ $db = undef;                                  # the DB_File handle
 %prefix_loc = ();                              # the meat of the info
 %pre = ();                                             # the prefix list
 $hits = $misses = $matchtotal = 1;             # cache stats
-$lrusize = 2000;                               # size of prefix LRU cache
-
-$lru = LRU->newbase('Prefix', $lrusize);
+$lrusize = 1000;                               # size of prefix LRU cache
 
 sub load
 {
@@ -43,6 +41,8 @@ sub load
                untie %pre;
                %pre = ();
                %prefix_loc = ();
+               $lru->close if $lru;
+               undef $lru;
        }
 
        # tie the main prefix database
@@ -50,6 +50,7 @@ sub load
        my $out = $@ if $@;
        do "$main::data/prefix_data.pl" if !$out;
        $out = $@ if $@;
+       $lru = LRU->newbase('Prefix', $lrusize);
 
        return $out;
 }