CVS: phpweather data_retrieval.php,1.21,1.22
Brought to you by:
iridium
From: Martin G. <gim...@us...> - 2002-04-12 22:10:46
|
Update of /cvsroot/phpweather/phpweather In directory usw-pr-cvs1:/tmp/cvs-serv18109 Modified Files: data_retrieval.php Log Message: We now use $this->properties['cache_timeout'] instead of the hardcoded 3600 seconds. Index: data_retrieval.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/data_retrieval.php,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- data_retrieval.php 22 Mar 2002 17:54:08 -0000 1.21 +++ data_retrieval.php 12 Apr 2002 22:10:43 -0000 1.22 @@ -157,7 +157,8 @@ * necessary. */ $this->metar = $metar; - if ($this->properties['always_use_db'] || $timestamp > time() - 3600) { + if ($this->properties['always_use_db'] || + $timestamp > time() - $this->properties['cache_timeout']) { /* We have asked explicit for a cached METAR, or the METAR is * still fresh. Either way - we return the METAR we found in @@ -165,13 +166,15 @@ */ $this->debug('get_metar_from_db(): Using previously cached METAR for <code>' . $this->get_location() . '</code>. The METAR expires in ' . - ($timestamp + 3600 - time()) . ' seconds.'); + ($timestamp + $this->properties['cache_timeout'] - time()) . + ' seconds.'); return $metar; } else { /* The METAR is too old, so we fetch new */ $this->debug('get_metar_from_db(): The METAR for <code>' . $this->get_location() . '</code> was ' . - (time() - 3600 - $timestamp) . ' seconds too old.'); + (time() - $this->properties['cache_timeout'] - $timestamp) . + ' seconds too old.'); return $this->get_metar_from_web(false); } } else { @@ -265,13 +268,13 @@ $metar = gmdate('dHi', $timestamp) . 'Z ' . $metar; } - if ($timestamp < (time() - 3300)) { + if ($timestamp < (time() - $this->properties['cache_timeout'] + 300)) { /* The timestamp in the METAR is more than 55 minutes old. We * adjust the timestamp, so that we won't try to fetch a new * METAR within the next 5 minutes. After 5 minutes, the * timestamp will again be more than 1 hour old. */ - $timestamp = time() - 3300; + $timestamp = time() - $this->properties['cache_timeout'] + 300; } } else { /* If we end up here, it means that there was no file. If the @@ -285,7 +288,7 @@ } else { $metar = $this->metar; } - $timestamp = time() - 3000; + $timestamp = time() - $this->properties['cache_timeout'] + 600; } /* We then cache the METAR in our database */ |