Req #28790 [Com]: Add php.ini option to disable stat cache

From: Date: Thu, 13 Feb 2014 14:54:37 +0000
Subject: Req #28790 [Com]: Add php.ini option to disable stat cache
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184287@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=28790&edit=1 ID: 28790 Comment by: roman at litgroup dot ru Reported by: jnoll at prim dot hu Summary: Add php.ini option to disable stat cache Status: Assigned Type: Feature/Change Request Package: *General Issues Operating System: * PHP Version: * Assigned To: pollita Block user comment: N Private report: N New Comment: We really need this option to disable cache in daemons, written in PHP. WebSocket server for example. Or some worker, which listens the queue and performs some jobs. Previous Comments: ------------------------------------------------------------------------ [2012-01-17 20:38:00] landeholm at gmail dot com Okay, the stat cache was not to blame for this problem I commented on above as I just learned it doesn't cache negative results but I still need a way to disable it. I could get problems in the future when file_exists returns true for a file that does not exist anymore. ------------------------------------------------------------------------ [2012-01-17 20:23:08] landeholm at gmail dot com I'm writing a PHP CLI daemon and the stat cache just burned me hard because it made file_exists() incorrectly return false for a file that had been created by another program. There NEEDS to be a way to disable this. My only option now appears to be to write my own file system wrapper functions to bypass this annoying behavior. ------------------------------------------------------------------------ [2011-03-31 08:34:39] rasmus@php.net You guys realize that the stat cache is per-request, right? You only need to clear the stat cache before a file_exists() call if you A. did a stat for it, and B. either created or deleted it on that request. In which case you shouldn't need to stat it again since the success status of the create/delete will tell you whether the file is there or not. Perhaps for long-running daemons or something this becomes more of an issue, but for a typical web request the stat cache typically saves you dozens of system calls. ------------------------------------------------------------------------ [2011-03-31 06:47:29] giorgio dot liscio at email dot it when this will be fixed? when lot of users work on same files is needed to clear the cache on every call to stat functions: this is totally annoying in plus clearing the cache every time is slower against not cache at all please fix :) thank you ------------------------------------------------------------------------ [2007-05-23 22:57:09] bcurry at freeshell dot org I'd like to second the motion for an .INI-option enabling the stat cache, defaulting to 'true.' In my case, I would certainly set this option to 'false.' In my humble opinion, the stat cache should either invalidate itself on every file access and modification - or not cache entries, at all. I depend on "file_exists" returning 'true' if a file exists, and 'false' if not. Enabling the stat cache makes this (and similar) built-in functions behave non-deterministically, and therefore un-reliably. The "speed" gain of caching stat results is surely obviated by the fact that, to obtain reliable stat results, one must call "clearstatcache" before every call to the "file_exists" (and similar) built-in functions. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=28790 -- Edit this bug report at https://bugs.php.net/bug.php?id=28790&edit=1

« previous php.bugs (#184287) next »