Re: Re: Pear::Cache lock files
| From: | Vinai Kopp | Date: | Thu, 14 Feb 2002 08:54:32 +0000 |
| Subject: | Re: Re: Pear::Cache lock files | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-4699@lists.php.net to get a copy of this message | ||
Hi,
with our quite busy site I experienced data corruption in cached data a couple of times. After set_file_buffer($f, 0) I never had problems again.
Also, to help avoid race conditions, I modified the cache classes so that when a process finds cached data to be expired, the expiration date is set to a couple secs in the future until the cache is updated with new data.
Other processes checking the cache will serve out the old data and won't attempt an update as well.
For our website it isn't critical if expired data is served for a couple of seconds.
Of course this doesn't inhibit race conditions, but it did reduce the number of concurrent processes generating the same data (almost allways to one :)
I prefere to work around file locking because of some fustrating experiences I had with it in the past.
I was a dirty hack, but if someone thinks it would be a good idea to put it in the "official" PEAR::Cache class, I'll clean it up and send a patch.
Greetings,
Vinai
i read that some problems could occurs if i use files to store the cached data, cause the files will not be locked while writing access. if there any plans to implement that or is that problem not so hard for middlesized websites ?Yes, PEAR Cache file container class does not assure mutual exclusion when updating a cache file. That can be a problem for sites of any size, but in sites with greater audience the probablity of cache data corruption is higher.