diff fetch_weather.pl @ 373:bc7746ca622e

fetch_weather: Implement purge_threshold setting.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 30 Jan 2016 00:55:43 +0200
parents 36869897f21d
children 26b7963e7fbd
line wrap: on
line diff
--- a/fetch_weather.pl	Sat Jan 30 00:28:14 2016 +0200
+++ b/fetch_weather.pl	Sat Jan 30 00:55:43 2016 +0200
@@ -488,12 +488,15 @@
 
 
 ###
-### Purge very old entries
+### Purge very old entries, default to 60 minutes
 ###
 my $wqtime = time();
+my $purge = opt_get_int("purge_threshold");
+$purge = 60 if ($purge <= 0);
+
 foreach my $key (keys %$weatherdata)
 {
-  if ($wqtime - $weatherdata->{$key}[1] > (60*60*6))
+  if ($wqtime - $weatherdata->{$key}[1] > (60 * $purge))
   {
     delete $$weatherdata{$key};
   }