- foreach $call (split /,/, $calls) {
- # first check if the whole thing succeeds
- my @nout = get($call);
- if (@nout && $nout[0] eq $call) {
- dbg("got exact prefix: $nout[0]") if isdbg('prefix');
- push @out, @nout;
+ # clear out the cache periodically to stop it growing for ever.
+ if ($main::systime - $lasttime >= 15*60) {
+ if (isdbg('prefix')) {
+ my $percent = $hits * 100 / $matchtotal;
+ dbg("Prefix Cache Cleared, Hits: $hits of $matchtotal = $percent\%")
+ }
+ my $percent = $hits * 100 / $matchtotal;
+ dbg("Prefix Cache Cleared, $percent\% hits") if isdbg('prefix');
+ %cache =();
+ $lasttime = $main::systime;
+ $hits = $matchtotal = 0;
+ }
+
+LM: foreach $call (split /,/, $calls) {
+
+ # first check if the whole thing succeeds either because it is cached
+ # or because it simply is a stored prefix as callsign (or even a prefix)
+ $matchtotal++;
+ my $p = $cache{$call};
+ my @nout;
+ if ($p) {
+ $hits++;
+ if (isdbg('prefix')) {
+ my $percent = $hits * 100 / $matchtotal;
+ dbg("Prefix Cache Hit: $call Hits: $hits of $matchtotal = $percent\%")
+ }
+ push @out, @$p;