|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-07-08 04:14 UTC] chx@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: chx
[2012-07-08 04:14 UTC] chx@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 14:00:02 2025 UTC |
Description: ------------ Perhaps there is a way to do this with apc_exists, but there doesn't seem to be an easy (fast, as in mostly C) way to see if a file already exists in the cache, other than using apc_cache_info (which is a bit crude). Typically I avoid using functions like file_exists / is_file when including class files (because of the stat). But in some situations it's useful to see if the file exists before including it, especially when you want to avoid a PHP warning. It would be nice if this function existed, and worked in the same way include/require does (by using include_path). I would envision something like this: apc_file_exists($filename, $compile=TRUE); When $compile is TRUE it tries to find the physical file and compile it. If it exists in the cache or was found and successfully compiled it would return TRUE, otherwise FALSE. When compile is FALSE it simply checks to see if the file is in the cache. If it is it returns TRUE, otherwise FALSE. An example of how it would be used: if(apc_file_exists('/path/to/foo.php')) { include('/path/to/foo.php'); } else { print 'The file doesn't exist!'; } Another possibility is to make file_exists or is_file work with APC :). Currently they return FALSE if the file exists in cache but not on disk. The best possible use for this is when apc.stat=0, which is awesome when updating production servers (replace the application files, clear cache).