This is PHP 5.6 x86
When using reroute_enabled=1, there seems to be an internal cache for functions such as file_exists() and others, but this cache - that I supposed was dependant on the same cache that is used for wincache.fcenabled=1 - seems to be completely unbound.
Take the following script:
$location = "d:\\dump.txt";
wincache_refresh_if_changed([$location]);
clearstatcache();
if (!file_exists($location)) {
file_put_contents($location, "<?php " . PHP_EOL);
}
file_put_contents($location, "THIS IS A LINE" . PHP_EOL);
return;
What I expect is that if I run this script, then manually delete the d:\\dump.txt file and run it again the call to file_exists() will return FALSE.
If using wincache.fcenabled=1 and reroute_enabled=0 it works as expected. Indeed, you don't even need the call to wincache_refresh_if_changed() or to clearstatcache(), propably the file system is notifying the cache that the file was deleted.
Buf if I use reroute_enabled=1 the nightmare starts. Once the file has been created, file_exists() will always return TRUE even if you manually delete the file from the file system, meaning that the calls to wincache_refresh_if_changed() or clearstatcache()
have no effect on whatever internal cache reroute_enabled is using.
I found that if I added unlink() at the end of the script to delete the file (instead of doing this manually) then the internal cache seems to become aware of the fact the the file is being deleted.
But this is confusing....
1. I expect that calling wincache_refresh_if_changed() will refresh whatever internal cache is being used. I would also expect this from clearstatcache() - even if they are different caches. Probably wincache should also be hooking into clearstatcache().
2. The fact that the documentation states that reroute_enabled=1 routes some function calls through the file cache (the one that is enabled with fcenabled=1) leaves me wondering what does the file cache do when reroute_enabled=0...
3. Wincache is supposed to internally receive file system notifications, so I can't understand why it is not being notified that the file was deleted - or if it is being notified - why is it not clearing/updating the cache used by reroute_enabled.
To make this more confusing, the docs don't make it clear what each cache does, and how do they work together.