I want to mention
http://php.net/manual/en/opcache.configuration.php#ini.opcache.enable-file-override
option, that can cache positive checks information between subsequent
requests.

Thanks!

2015-03-20 9:13 GMT+03:00 Stanislav Malyshev <smalys...@gmail.com>:

> Hi!
>
> > 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?
>
> Negative cache is tricky. Most frequent patterns look like this:
>
> 1. if(file_exists("blah")) { do stuff }
>
> 2. if(!file_exists("blah")) { throw new Exception("no blah!"); }
> do stuff
>
> 3. if(!file_exists("blah")) { create("blah"); }
> do stuff
>
> Caching negative even short term would subtly break case 3, in that it
> would force creation of the file every time, thus killing any benefit
> from any caching (usually file creation is much more expensive process).
> Long term caching would also be big trouble with case 2. Unless there's
> a way to reset the cache and the app is very careful to do it - but file
> can be created by external means and also case 2 would be harder to fix
> without losing the benefits of caching.
>
> So one may ask, why case 1 is not a problem? Usually it's because if the
> file is there, apps rarely delete them by themselves, or at least adding
> new files is much more frequent operation than deleting existing ones
> that are used by the app.
> --
> Stas Malyshev
> smalys...@gmail.com
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to