comparison fetch_weather.pl @ 394:315f31e4f964

fetch_weather: Make purge_threshold option entirely optional, e.g. not set or 0 will disable purging.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Jan 2017 23:14:55 +0200
parents afd9a2bc8626
children 33b5e7adc30c
comparison
equal deleted inserted replaced
393:9a33575eb999 394:315f31e4f964
527 ### Skip here if the FMI shit fails due to broken data 527 ### Skip here if the FMI shit fails due to broken data
528 skip_it: 528 skip_it:
529 529
530 530
531 ### 531 ###
532 ### Purge very old entries, default to 60 minutes 532 ### Purge too old entries
533 ### 533 ###
534 my $wqtime = time(); 534 if (opt_chk_valid("purge_threshold", 1))
535 my $purge = opt_get_int("purge_threshold"); 535 {
536 $purge = 60 if ($purge <= 0); 536 my $purge = opt_get_int("purge_threshold");
537 537 if ($purge > 0)
538 foreach my $key (keys %$weatherdata) 538 {
539 { 539 my $wqtime = time();
540 if ($wqtime - $weatherdata->{$key}[1] > (60 * $purge)) 540
541 { 541 foreach my $key (keys %$weatherdata)
542 delete $$weatherdata{$key}; 542 {
543 if ($wqtime - $weatherdata->{$key}[1] > (60 * $purge))
544 {
545 delete $$weatherdata{$key};
546 }
547 }
543 } 548 }
544 } 549 }
545 550
546 551
547 ### 552 ###