Re: [Q] Does PHP have a negative cache for file stat operations?

From: Date: Fri, 20 Mar 2015 01:13:13 +0000
Subject: Re: [Q] Does PHP have a negative cache for file stat operations?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-85257@lists.php.net to get a copy of this message
On Fri, Mar 20, 2015 at 12:09 PM, Rasmus Lerdorf <rasmus@lerdorf.com> wrote: > On 03/19/2015 01:26 PM, Eric Stenson wrote: >> PHP Internals folks-- >> >> We're doing some performance work in WinCache, and we're finding that some >> frameworks are...uh...enthusiastically using file_exists(), is_file() and is_dir() functions on >> files/directories that don't exist. Every. Single. Pageload. >> >> Does the PHP stat cache include negative cache entries? If not, why not? >> >> Are there any existing extensions that implement a negative cache for file_exists(), >> is_file(), et. al.? > > We do not do negative caching. This is documented at > http://php.net/manual/en/function.clearstatcache.php where it > says: > > You should also note that PHP doesn't cache information about > non-existent files. So, if you call file_exists() on a file that > doesn't exist, it will return FALSE until you create the file. If you > create the file, it will return TRUE even if you then delete the > file. However unlink() clears the cache automatically. > > But, I think you are also missing the fact that the stat cache is > per-request. So your "every single pageload" aspect won't be helped by > adding negative caching to the stat cache. It is still going to stat on > every single page load. It is only multiple identical stats within the > same request that gets caught by the stat cache. Thanks :) I forgot to mention that here (but in a chat :). Also it would help a little bit as some apps repeatedly check files or paths in the same request. However I am not sure it is worth the addition. Cheers, -- Pierre @pierrejoye | http://www.libgd.org

« previous php.internals (#85257) next »