Re: contributing / disapointed
| From: | MARTY Fabien | Date: | Mon, 27 May 2002 22:41:29 +0000 |
| Subject: | Re: contributing / disapointed | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-6497@lists.php.net to get a copy of this message | ||
(Sebastian)
> > -0 from me for adding HTTP_Request to PEAR Cache. Caching a document
> > from an URL is about 5 LOC with Cache_Function...
(Richard)
> Not having looked at Cache_Function, does this 5 loc do everything
> HTTP_Request does? ie Basic/Proxy Auth, get/post etc
Cache_Function can cache every function return. So if you cache the call of
HTTP_Request, you can do that. I didn't test but it must work I think.
Yet, I don't agree with Sebastian. Because, I knew Cache_Function when I
write Cache_HTTP_Request. I need a very usefull feature that it's not easy to
write with only Cache_Function :
- when the remote server is down, HTTP_Request can return the latest local
copy of the remote file.
These feature is very usefull when you display news of another site (with RSS
for example). Every x hours, you send a request to the remote server to get
the RSS file. Then, your site is updated with the result. But, if the remote
server is dead, you will have problems with your own site. So, I need a class
which returns the latest local copy in this case. Then, visitors won't remark
any problem with my pages. I think it's not directly possible with
Cache_Function. And that's why I wrote Cache_HTTP_Request.
<technical>
Why is not directly possible with Cache_Function ?
Cache_Function make a cache file with a given lifetime. But this file can be
destroyed by a simple call to isExpired() or only by garbage collection
(called sometimes through the destructor). So you can't control this file. If
it is destroyed when you update the cache, you won't be able to return the
latest valid copy of the remote file.
So to implement the feature I need, Cache_HTTP_Request has two cache files.
The first one has a given lifetime. And the second one can't be destroyed
(lifetime=0). Contents are the same. But if the remote server is down when
the cache is updated, the class will use the second cache to return the
latest valid copy of the remote file...
Maybe it's not clear. Have a look at the code :
http://www.sousmarin.net/HTTP_Request.txt
</technical>
So, I think HTTP_Request has features that you can't implement directly with
Cache_Function.
I hope you will understand my point of vue.
I wil not commit anything if you still don't agree with me.
Thanks,
Fabien