- my @out = get($s);
- if (isdbg('prefix')) {
- my $part = $out[0] || "*";
- $part .= '*' unless $part eq '*' || $part eq $s;
- dbg("Partial prefix: $pref $s $part" );
- }
- return @out if @out && $out[0] eq $s;
+ push @partials, $s;
+ my $p = $lru->get($s);
+ if ($p) {
+ $hits++;
+ if (isdbg('prefix')) {
+ my $percent = sprintf "%.1f", $hits * 100 / $misses;
+ dbg("Partial Prefix Cache Hit: $s Hits: $hits/$misses of $matchtotal = $percent\%");
+ }
+ $lru->put($_, $p) for @partials;
+ return @$p;
+ } else {
+ $misses++;
+ my @out = get($s);
+ if (isdbg('prefix')) {
+ my $part = $out[0] || "*";
+ $part .= '*' unless $part eq '*' || $part eq $s;
+ dbg("Partial prefix: $pref $s $part" );
+ }
+ if (@out && $out[0] eq $s) {
+ $lru->put($_, \@out) for @partials;
+ return @out;
+ }
+ }