From b00e85c55392ddf0593b681d7187e4c4e158568e Mon Sep 17 00:00:00 2001 From: minima Date: Tue, 29 Oct 2002 15:35:29 +0000 Subject: [PATCH] flush lru cache on reload --- Changes | 1 + perl/Chain.pm | 7 +++++++ perl/Prefix.pm | 7 ++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 9418f1f6..62800dd0 100644 --- 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 diff --git a/perl/Chain.pm b/perl/Chain.pm index c4fa99a7..c065d17a 100644 --- a/perl/Chain.pm +++ b/perl/Chain.pm @@ -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! diff --git a/perl/Prefix.pm b/perl/Prefix.pm index 5733ff02..6f1c1f29 100644 --- a/perl/Prefix.pm +++ b/perl/Prefix.pm @@ -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; } -- 2.34.1