read verses spew

Post Reply
gerry.odea
Posts: 96
Joined: Fri Sep 19, 2008 9:33 am

read verses spew

Post by gerry.odea »

I'm currently using this code below to cache data. The ouput is saved with the WRITE statement. My question is, would it be better if I used the spew statement instead of the read statement? Also is there a way to read the date of the file this way if it's older than a week I could write over it.
Thanks,
Gerry

<IF $page lt 2>
<lower $q2><$searchdirectory="/a/"><$storesearch=($searchdirectory+$ret)><read $storesearch>
<fetch "http://1.1.1.1" $ret><$html=$ret>
<timport max=2 row $imports $html></timport>
<IF $EN="">
<fetch PARALLEL $fetchsearch><$html=$ret></fetch>
<lower $q2><$searchdirectory="/a/"><$storesearch=($searchdirectory+$ret)><WRITE SKIPONFAIL $storesearch><fmt "%s" $html></WRITE>
</IF>
<ELSE>
<fetch PARALLEL $fetchsearch><$html=$ret></fetch>
</if>
User avatar
mark
Site Admin
Posts: 5493
Joined: Tue Apr 25, 2000 6:56 pm

read verses spew

Post by mark »

You're reprocessing the file you <read> so spew would not be appropriate. If you were sending the file from disk directly out, then you would use <spew>.

Use <stat> to get file mod times etc.
gerry.odea
Posts: 96
Joined: Fri Sep 19, 2008 9:33 am

read verses spew

Post by gerry.odea »

Thanks Mark!
I still can't get this to work, it won't save anything to $FDate

<lower $q2><$searchdirectory="/a/"><$storesearch=($searchdirectory+$ret)><stat $storesearch><$FDate=$ret.mtime>
User avatar
Kai
Site Admin
Posts: 1263
Joined: Tue Apr 25, 2000 1:27 pm

read verses spew

Post by Kai »

Check (print) $ret.err after the <stat>: if it's non-empty, an error occurred trying to stat the file. Also print $storesearch to verify it's the correct path.
Post Reply