Skip to content

Commit

Permalink
Fix cache
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Mar 17, 2019
1 parent f32cf67 commit 8942aec
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/Geo/Coder/List.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Version 0.23
=cut

our $VERSION = '0.23';
our %locations;
our %locations; # L1 cache, always used

=head1 SYNOPSIS
Expand Down Expand Up @@ -436,9 +436,21 @@ sub flush {
sub _cache {
my $self = shift;
my $key = shift;

if(my $value = shift) {
$locations{$key} = $value;
if($self->{'cache'}) {
if(ref($value) eq 'ARRAY') {
foreach my $item(@{$value}) {
foreach my $key(keys(%{$item})) {
delete $item->{$key} unless ($key eq 'geometry');
}
}
} else {
foreach my $key(keys(%{$value})) {
delete $value->{$key} unless ($key eq 'geometry');
}
}
$self->{'cache'}->set($key, $value, '1 month');
}
}
Expand Down

0 comments on commit 8942aec

Please sign in to comment.