Re: Package proposal: Payment_Exchange

From: Date: Thu, 28 Aug 2003 12:55:22 +0000
Subject: Re: Package proposal: Payment_Exchange
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-20747@lists.php.net to get a copy of this message
On Thu, 2003-08-28 at 12:04, Marshall Roch wrote: > Bruno Pedro wrote: > > If the exchange rate feed is published daily, what is the need of > > caching it hourly? > > So that you'll at most only be delayed an hour when the feed updates. > It's published on a regular schedule, but Cache_HTTP_Request doesn't > have a way to only update at certain times of day/month/year. That > feature was just requested by Stefan Neufeind, so maybe we will be able > to fix this soon. Take a look at this code: <?php require_once 'Cache/HTTP_Request.php'; $cacheLife = 3600; $cache =& new Cache_HTTP_Request('http://www.php.net', NULL, 'file', NULL, $cacheLife); $cache->sendRequest(); $dayNow = date('d'); $dayCached = date('d', $cache->container->expires - $cacheLife); if ($dayNow > $dayCached) { $cache->sendRequest(); } $remoteFileBody = $cache->getResponseBody(); ?> By comparing the day of the cache with the current day you can actually do a 'once a day' operation. What do you think? -- Bruno Pedro PTM.com Key fingerprint = B398 3A92 704F C74D A984 2424 26F0 189E 9FEE CDC8 http://search.keyserver.net:11371/pks/lookup?op=get&search=0x9FEECDC8

Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc
« previous php.pear.dev (#20747) next »