Re: Function Cache

From: Date: Sun, 10 Dec 2000 20:02:16 +0000
Subject: Re: Function Cache
References: 1 2 3 4 5  Groups: php.pear 
Request: Send a blank email to php-pear+get-636@lists.php.net to get a copy of this message
On Sun, Dec 10, 2000 at 07:45:36PM +0100, Sebastian Bergmann wrote: > Tim Perdue wrote: > > I see your semaphores. But in cache_call(), between the _cache_init() > > call and the expiration test, another process could have overwritten and > > refreshed the shared memory, meaning you wouldn't need to recreate it > > and re-write it to shmem. > > *ouch* > > Any hints on how to improve this? BTW it's in the PEAR CVS now, so others > can start developing it, too :-) I'll look at it more. Basically after the test for expiration, if it's expired, you need an exclusive lock on shmem, then fetch and test for expiration again. If it's still expired, then write to shmem and release the exclusive lock. Right now, if you have 200 apache processes running, all 200 of them will see it expire at the same moment and attempt to re-cache. Tim -- Founder - PHPBuilder.com / Geocrawler.com Lead Developer - SourceForge VA Linux Systems

« previous php.pear (#636) next »